Commit 02d6822001c90d3c5e2804a4e00f2a8c246e5138
1 parent
314fe766
Exists in
master
and in
1 other branch
fix spec/model/user with fabrication_gem
Showing
1 changed file
with
10 additions
and
10 deletions
Show diff stats
spec/models/user_spec.rb
| @@ -4,7 +4,7 @@ describe User do | @@ -4,7 +4,7 @@ describe User do | ||
| 4 | 4 | ||
| 5 | context 'validations' do | 5 | context 'validations' do |
| 6 | it 'require that a name is present' do | 6 | it 'require that a name is present' do |
| 7 | - user = Factory.build(:user, :name => nil) | 7 | + user = Fabricate.build(:user, :name => nil) |
| 8 | user.should_not be_valid | 8 | user.should_not be_valid |
| 9 | user.errors[:name].should include("can't be blank") | 9 | user.errors[:name].should include("can't be blank") |
| 10 | end | 10 | end |
| @@ -13,26 +13,26 @@ describe User do | @@ -13,26 +13,26 @@ describe User do | ||
| 13 | context 'Watchers' do | 13 | context 'Watchers' do |
| 14 | 14 | ||
| 15 | it 'has many watchers' do | 15 | it 'has many watchers' do |
| 16 | - user = Factory(:user) | ||
| 17 | - watcher = Factory(:user_watcher, :user => user) | 16 | + user = Fabricate(:user) |
| 17 | + watcher = Fabricate(:user_watcher, :user => user) | ||
| 18 | user.watchers.should_not be_empty | 18 | user.watchers.should_not be_empty |
| 19 | user.watchers.should include(watcher) | 19 | user.watchers.should include(watcher) |
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | it "destroys any related watchers when it is destroyed" do | 22 | it "destroys any related watchers when it is destroyed" do |
| 23 | - user = Factory(:user) | ||
| 24 | - app = Factory(:app) | ||
| 25 | - watcher = Factory(:user_watcher, :app => app, :user => user) | 23 | + user = Fabricate(:user) |
| 24 | + app = Fabricate(:app) | ||
| 25 | + watcher = Fabricate(:user_watcher, :app => app, :user => user) | ||
| 26 | user.watchers.should_not be_empty | 26 | user.watchers.should_not be_empty |
| 27 | user.destroy | 27 | user.destroy |
| 28 | app.reload.watchers.should_not include(watcher) | 28 | app.reload.watchers.should_not include(watcher) |
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | it "has many apps through watchers" do | 31 | it "has many apps through watchers" do |
| 32 | - user = Factory(:user) | ||
| 33 | - watched_app = Factory(:app) | ||
| 34 | - unwatched_app = Factory(:app) | ||
| 35 | - watcher = Factory(:user_watcher, :app => watched_app, :user => user) | 32 | + user = Fabricate(:user) |
| 33 | + watched_app = Fabricate(:app) | ||
| 34 | + unwatched_app = Fabricate(:app) | ||
| 35 | + watcher = Fabricate(:user_watcher, :app => watched_app, :user => user) | ||
| 36 | user.apps.all.should include(watched_app) | 36 | user.apps.all.should include(watched_app) |
| 37 | user.apps.all.should_not include(unwatched_app) | 37 | user.apps.all.should_not include(unwatched_app) |
| 38 | end | 38 | end |