Commit b717ccfb31afcdd9463b70229d668b60107c9f0e
1 parent
d77668a0
Exists in
master
and in
1 other branch
List users by name on app edit forms.
Showing
3 changed files
with
15 additions
and
1 deletions
Show diff stats
app/controllers/apps_controller.rb
@@ -36,6 +36,10 @@ class AppsController < ApplicationController | @@ -36,6 +36,10 @@ class AppsController < ApplicationController | ||
36 | app.deploys.order_by(:created_at.desc).limit(5) | 36 | app.deploys.order_by(:created_at.desc).limit(5) |
37 | } | 37 | } |
38 | 38 | ||
39 | + expose(:users) { | ||
40 | + User.all.asc(:name) | ||
41 | + } | ||
42 | + | ||
39 | def index; end | 43 | def index; end |
40 | def show | 44 | def show |
41 | app | 45 | app |
app/views/apps/_fields.html.haml
@@ -55,7 +55,7 @@ | @@ -55,7 +55,7 @@ | ||
55 | = w.radio_button :watcher_type, :email | 55 | = w.radio_button :watcher_type, :email |
56 | = label_tag :watcher_type_email, 'Email Address', :for => label_for_attr(w, 'watcher_type_email') | 56 | = label_tag :watcher_type_email, 'Email Address', :for => label_for_attr(w, 'watcher_type_email') |
57 | %div.watcher_params.user{:class => w.object.email.blank? ? 'chosen' : nil} | 57 | %div.watcher_params.user{:class => w.object.email.blank? ? 'chosen' : nil} |
58 | - = w.select :user_id, User.all.map{|u| [u.name,u.id.to_s]}, :include_blank => '-- Select a User --' | 58 | + = w.select :user_id, users.map{|u| [u.name,u.id.to_s]}, :include_blank => '-- Select a User --' |
59 | %div.watcher_params.email{:class => w.object.email.present? ? 'chosen' : nil} | 59 | %div.watcher_params.email{:class => w.object.email.present? ? 'chosen' : nil} |
60 | = w.text_field :email | 60 | = w.text_field :email |
61 | 61 |
spec/controllers/apps_controller_spec.rb
@@ -73,6 +73,16 @@ describe AppsController do | @@ -73,6 +73,16 @@ describe AppsController do | ||
73 | expect(response).to be_success | 73 | expect(response).to be_success |
74 | end | 74 | end |
75 | 75 | ||
76 | + it "should list available watchers by name" do | ||
77 | + Fabricate(:user, :name => "Carol") | ||
78 | + Fabricate(:user, :name => "Alice") | ||
79 | + Fabricate(:user, :name => "Betty") | ||
80 | + | ||
81 | + get :show, :id => app.id | ||
82 | + | ||
83 | + expect(controller.users.to_a).to eq(User.all.to_a.sort_by(&:name)) | ||
84 | + end | ||
85 | + | ||
76 | context "pagination" do | 86 | context "pagination" do |
77 | before(:each) do | 87 | before(:each) do |
78 | 35.times { Fabricate(:err, :problem => Fabricate(:problem, :app => app)) } | 88 | 35.times { Fabricate(:err, :problem => Fabricate(:problem, :app => app)) } |