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
@@ -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.sort_by {|u| u.name.downcase } | ||
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 | ||
@@ -65,4 +65,3 @@ | @@ -65,4 +65,3 @@ | ||
65 | 65 | ||
66 | = render "issue_tracker_fields", :f => f | 66 | = render "issue_tracker_fields", :f => f |
67 | = render "service_notification_fields", :f => f | 67 | = render "service_notification_fields", :f => f |
68 | - |
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)) } |
@@ -392,4 +402,3 @@ describe AppsController do | @@ -392,4 +402,3 @@ describe AppsController do | ||
392 | end | 402 | end |
393 | 403 | ||
394 | end | 404 | end |
395 | - |