Commit aaf30eff52184636c6c5bbfec721838bb70ddaf8
Exists in
master
and in
1 other branch
Merge pull request #704 from elliotcm/sort-users-by-name
Looks good. Thanks for your contribution.
Showing
3 changed files
with
15 additions
and
3 deletions
Show diff stats
app/controllers/apps_controller.rb
app/views/apps/_fields.html.haml
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | = w.radio_button :watcher_type, :email |
56 | 56 | = label_tag :watcher_type_email, 'Email Address', :for => label_for_attr(w, 'watcher_type_email') |
57 | 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 | 59 | %div.watcher_params.email{:class => w.object.email.present? ? 'chosen' : nil} |
60 | 60 | = w.text_field :email |
61 | 61 | |
... | ... | @@ -65,4 +65,3 @@ |
65 | 65 | |
66 | 66 | = render "issue_tracker_fields", :f => f |
67 | 67 | = render "service_notification_fields", :f => f |
68 | - | ... | ... |
spec/controllers/apps_controller_spec.rb
... | ... | @@ -73,6 +73,16 @@ describe AppsController do |
73 | 73 | expect(response).to be_success |
74 | 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 | 86 | context "pagination" do |
77 | 87 | before(:each) do |
78 | 88 | 35.times { Fabricate(:err, :problem => Fabricate(:problem, :app => app)) } |
... | ... | @@ -392,4 +402,3 @@ describe AppsController do |
392 | 402 | end |
393 | 403 | |
394 | 404 | end |
395 | - | ... | ... |