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