Commit 519822dad87a14d2248097922f02ee0353a79e0b

Authored by Cyril Mougel
1 parent 3bb9e3cc
Exists in master and in 1 other branch production

fix spec controller/users to fabrication_gem

Showing 1 changed file with 14 additions and 14 deletions   Show diff stats
spec/controllers/users_controller_spec.rb
@@ -14,16 +14,16 @@ describe UsersController do @@ -14,16 +14,16 @@ describe UsersController do
14 14
15 context 'Signed in as a regular user' do 15 context 'Signed in as a regular user' do
16 before do 16 before do
17 - sign_in @user = Factory(:user) 17 + sign_in @user = Fabricate(:user)
18 end 18 end
19 - 19 +
20 it "should set a time zone" do 20 it "should set a time zone" do
21 Time.zone.should.to_s == @user.time_zone 21 Time.zone.should.to_s == @user.time_zone
22 end 22 end
23 23
24 context "GET /users/:other_id/edit" do 24 context "GET /users/:other_id/edit" do
25 it "redirects to the home page" do 25 it "redirects to the home page" do
26 - get :edit, :id => Factory(:user).id 26 + get :edit, :id => Fabricate(:user).id
27 response.should redirect_to(root_path) 27 response.should redirect_to(root_path)
28 end 28 end
29 end 29 end
@@ -47,7 +47,7 @@ describe UsersController do @@ -47,7 +47,7 @@ describe UsersController do
47 47
48 context "PUT /users/:other_id" do 48 context "PUT /users/:other_id" do
49 it "redirects to the home page" do 49 it "redirects to the home page" do
50 - put :update, :id => Factory(:user).id 50 + put :update, :id => Fabricate(:user).id
51 response.should redirect_to(root_path) 51 response.should redirect_to(root_path)
52 end 52 end
53 end 53 end
@@ -73,7 +73,7 @@ describe UsersController do @@ -73,7 +73,7 @@ describe UsersController do
73 put :update, :id => @user.to_param, :user => {:per_page => 555} 73 put :update, :id => @user.to_param, :user => {:per_page => 555}
74 @user.reload.per_page.should == 555 74 @user.reload.per_page.should == 555
75 end 75 end
76 - 76 +
77 it "should be able to set time_zone option" do 77 it "should be able to set time_zone option" do
78 put :update, :id => @user.to_param, :user => {:time_zone => "Warsaw"} 78 put :update, :id => @user.to_param, :user => {:time_zone => "Warsaw"}
79 @user.reload.time_zone.should == "Warsaw" 79 @user.reload.time_zone.should == "Warsaw"
@@ -91,14 +91,14 @@ describe UsersController do @@ -91,14 +91,14 @@ describe UsersController do
91 91
92 context 'Signed in as an admin' do 92 context 'Signed in as an admin' do
93 before do 93 before do
94 - @user = Factory(:admin) 94 + @user = Fabricate(:admin)
95 sign_in @user 95 sign_in @user
96 end 96 end
97 97
98 context "GET /users" do 98 context "GET /users" do
99 it 'paginates all users' do 99 it 'paginates all users' do
100 @user.update_attribute :per_page, 2 100 @user.update_attribute :per_page, 2
101 - users = 3.times { Factory(:user) } 101 + users = 3.times { Fabricate(:user) }
102 get :index 102 get :index
103 assigns(:users).to_a.size.should == 2 103 assigns(:users).to_a.size.should == 2
104 end 104 end
@@ -106,7 +106,7 @@ describe UsersController do @@ -106,7 +106,7 @@ describe UsersController do
106 106
107 context "GET /users/:id" do 107 context "GET /users/:id" do
108 it 'finds the user' do 108 it 'finds the user' do
109 - user = Factory(:user) 109 + user = Fabricate(:user)
110 get :show, :id => user.id 110 get :show, :id => user.id
111 assigns(:user).should == user 111 assigns(:user).should == user
112 end 112 end
@@ -122,7 +122,7 @@ describe UsersController do @@ -122,7 +122,7 @@ describe UsersController do
122 122
123 context "GET /users/:id/edit" do 123 context "GET /users/:id/edit" do
124 it 'finds the user' do 124 it 'finds the user' do
125 - user = Factory(:user) 125 + user = Fabricate(:user)
126 get :edit, :id => user.id 126 get :edit, :id => user.id
127 assigns(:user).should == user 127 assigns(:user).should == user
128 end 128 end
@@ -131,7 +131,7 @@ describe UsersController do @@ -131,7 +131,7 @@ describe UsersController do
131 context "POST /users" do 131 context "POST /users" do
132 context "when the create is successful" do 132 context "when the create is successful" do
133 before do 133 before do
134 - @attrs = {:user => Factory.attributes_for(:user)} 134 + @attrs = {:user => Fabricate.attributes_for(:user)}
135 end 135 end
136 136
137 it "sets a message to display" do 137 it "sets a message to display" do
@@ -159,7 +159,7 @@ describe UsersController do @@ -159,7 +159,7 @@ describe UsersController do
159 159
160 context "when the create is unsuccessful" do 160 context "when the create is unsuccessful" do
161 before do 161 before do
162 - @user = Factory(:user) 162 + @user = Fabricate(:user)
163 User.should_receive(:new).and_return(@user) 163 User.should_receive(:new).and_return(@user)
164 @user.should_receive(:save).and_return(false) 164 @user.should_receive(:save).and_return(false)
165 end 165 end
@@ -174,7 +174,7 @@ describe UsersController do @@ -174,7 +174,7 @@ describe UsersController do
174 context "PUT /users/:id" do 174 context "PUT /users/:id" do
175 context "when the update is successful" do 175 context "when the update is successful" do
176 before do 176 before do
177 - @user = Factory(:user) 177 + @user = Fabricate(:user)
178 end 178 end
179 179
180 it "sets a message to display" do 180 it "sets a message to display" do
@@ -196,7 +196,7 @@ describe UsersController do @@ -196,7 +196,7 @@ describe UsersController do
196 196
197 context "when the update is unsuccessful" do 197 context "when the update is unsuccessful" do
198 before do 198 before do
199 - @user = Factory(:user) 199 + @user = Fabricate(:user)
200 end 200 end
201 201
202 it "renders the edit page" do 202 it "renders the edit page" do
@@ -208,7 +208,7 @@ describe UsersController do @@ -208,7 +208,7 @@ describe UsersController do
208 208
209 context "DELETE /users/:id" do 209 context "DELETE /users/:id" do
210 before do 210 before do
211 - @user = Factory(:user) 211 + @user = Fabricate(:user)
212 end 212 end
213 213
214 it "destroys the user" do 214 it "destroys the user" do