Commit 5ea3456100c96aabe225f89fee069f4d8545a96e
1 parent
a45142ac
Exists in
master
and in
1 other branch
Update tests now that you must specify watcher_type to differentiate between user and email watchers
Showing
5 changed files
with
20 additions
and
13 deletions
Show diff stats
spec/controllers/apps_controller_spec.rb
... | ... | @@ -22,8 +22,8 @@ describe AppsController do |
22 | 22 | unwatched_app = Factory(:app) |
23 | 23 | watched_app1 = Factory(:app) |
24 | 24 | watched_app2 = Factory(:app) |
25 | - Factory(:watcher, :user => user, :app => watched_app1) | |
26 | - Factory(:watcher, :user => user, :app => watched_app2) | |
25 | + Factory(:user_watcher, :user => user, :app => watched_app1) | |
26 | + Factory(:user_watcher, :user => user, :app => watched_app2) | |
27 | 27 | get :index |
28 | 28 | assigns(:apps).should include(watched_app1, watched_app2) |
29 | 29 | assigns(:apps).should_not include(unwatched_app) | ... | ... |
spec/controllers/errs_controller_spec.rb
... | ... | @@ -28,8 +28,8 @@ describe ErrsController do |
28 | 28 | it 'gets a paginated list of unresolved errs for the users apps' do |
29 | 29 | sign_in(user = Factory(:user)) |
30 | 30 | unwatched_err = Factory(:err) |
31 | - watched_unresolved_err = Factory(:err, :app => Factory(:watcher, :user => user).app, :resolved => false) | |
32 | - watched_resolved_err = Factory(:err, :app => Factory(:watcher, :user => user).app, :resolved => true) | |
31 | + watched_unresolved_err = Factory(:err, :app => Factory(:user_watcher, :user => user).app, :resolved => false) | |
32 | + watched_resolved_err = Factory(:err, :app => Factory(:user_watcher, :user => user).app, :resolved => true) | |
33 | 33 | get :index |
34 | 34 | assigns(:errs).should include(watched_unresolved_err) |
35 | 35 | assigns(:errs).should_not include(unwatched_err, watched_resolved_err) |
... | ... | @@ -56,8 +56,8 @@ describe ErrsController do |
56 | 56 | it 'gets a paginated list of all errs for the users apps' do |
57 | 57 | sign_in(user = Factory(:user)) |
58 | 58 | unwatched_err = Factory(:err) |
59 | - watched_unresolved_err = Factory(:err, :app => Factory(:watcher, :user => user).app, :resolved => false) | |
60 | - watched_resolved_err = Factory(:err, :app => Factory(:watcher, :user => user).app, :resolved => true) | |
59 | + watched_unresolved_err = Factory(:err, :app => Factory(:user_watcher, :user => user).app, :resolved => false) | |
60 | + watched_resolved_err = Factory(:err, :app => Factory(:user_watcher, :user => user).app, :resolved => true) | |
61 | 61 | get :all |
62 | 62 | assigns(:errs).should include(watched_resolved_err, watched_unresolved_err) |
63 | 63 | assigns(:errs).should_not include(unwatched_err) |
... | ... | @@ -100,7 +100,7 @@ describe ErrsController do |
100 | 100 | sign_in(@user = Factory(:user)) |
101 | 101 | @unwatched_err = Factory(:err) |
102 | 102 | @watched_app = Factory(:app) |
103 | - @watcher = Factory(:watcher, :user => @user, :app => @watched_app) | |
103 | + @watcher = Factory(:user_watcher, :user => @user, :app => @watched_app) | |
104 | 104 | @watched_err = Factory(:err, :app => @watched_app) |
105 | 105 | end |
106 | 106 | ... | ... |
spec/factories/app_factories.rb
... | ... | @@ -12,10 +12,16 @@ Factory.define(:app_with_watcher, :parent => :app) do |p| |
12 | 12 | end |
13 | 13 | |
14 | 14 | Factory.define(:watcher) do |w| |
15 | - w.app {|p| p.association :app} | |
15 | + w.association :app | |
16 | + w.watcher_type 'email' | |
16 | 17 | w.email { Factory.next :email } |
17 | 18 | end |
18 | 19 | |
20 | +Factory.define(:user_watcher, :parent => :watcher) do |w| | |
21 | + w.watcher_type 'user' | |
22 | + w.association :user | |
23 | +end | |
24 | + | |
19 | 25 | Factory.define(:deploy) do |d| |
20 | 26 | d.app {|p| p.association :app} |
21 | 27 | d.username 'clyde.frog' | ... | ... |
spec/models/user_spec.rb
... | ... | @@ -14,7 +14,7 @@ describe User do |
14 | 14 | |
15 | 15 | it 'has many watchers' do |
16 | 16 | user = Factory(:user) |
17 | - watcher = Factory(:watcher, :user => user, :email => nil) | |
17 | + watcher = Factory(:user_watcher, :user => user) | |
18 | 18 | user.watchers.should_not be_empty |
19 | 19 | user.watchers.should include(watcher) |
20 | 20 | end |
... | ... | @@ -22,7 +22,7 @@ describe User do |
22 | 22 | it "destroys any related watchers when it is destroyed" do |
23 | 23 | user = Factory(:user) |
24 | 24 | app = Factory(:app) |
25 | - watcher = Factory(:watcher, :app => app, :user => user, :email => nil) | |
25 | + watcher = Factory(:user_watcher, :app => app, :user => user) | |
26 | 26 | user.watchers.should_not be_empty |
27 | 27 | user.destroy |
28 | 28 | app.reload.watchers.should_not include(watcher) |
... | ... | @@ -32,7 +32,7 @@ describe User do |
32 | 32 | user = Factory(:user) |
33 | 33 | watched_app = Factory(:app) |
34 | 34 | unwatched_app = Factory(:app) |
35 | - watcher = Factory(:watcher, :app => watched_app, :user => user, :email => nil) | |
35 | + watcher = Factory(:user_watcher, :app => watched_app, :user => user) | |
36 | 36 | user.apps.all.should include(watched_app) |
37 | 37 | user.apps.all.should_not include(unwatched_app) |
38 | 38 | end | ... | ... |
spec/models/watcher_spec.rb
... | ... | @@ -15,6 +15,7 @@ describe Watcher do |
15 | 15 | watcher.should_not be_valid |
16 | 16 | |
17 | 17 | watcher.user = Factory(:user) |
18 | + watcher.watcher_type = 'user' | |
18 | 19 | watcher.should be_valid |
19 | 20 | end |
20 | 21 | end |
... | ... | @@ -22,12 +23,12 @@ describe Watcher do |
22 | 23 | context 'address' do |
23 | 24 | it "returns the user's email address if there is a user" do |
24 | 25 | user = Factory(:user, :email => 'foo@bar.com') |
25 | - watcher = Factory(:watcher, :user => user) | |
26 | + watcher = Factory(:user_watcher, :user => user) | |
26 | 27 | watcher.address.should == 'foo@bar.com' |
27 | 28 | end |
28 | 29 | |
29 | 30 | it "returns the email if there is no user" do |
30 | - watcher = Factory(:watcher, :email => 'widgets@acme.com', :user => nil) | |
31 | + watcher = Factory(:watcher, :email => 'widgets@acme.com') | |
31 | 32 | watcher.address.should == 'widgets@acme.com' |
32 | 33 | end |
33 | 34 | end | ... | ... |