aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-07-14 01:14:44 +0100
committerFrancis Irving <francis@mysociety.org>2010-07-14 01:14:44 +0100
commit57de5cb0a4de67e196984d16f91d973df4aebc2d (patch)
tree2ef2dd804de62e9ef074459d8363f33a032e1471
parentd82960021cbe2c4501be1012e2d040b76c728e23 (diff)
Factor out common bits.
-rw-r--r--spec/controllers/user_controller_spec.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 19225c6ae..832ac718c 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -456,21 +456,23 @@ end
describe UserController, "when using profile photos" do
integrate_views
fixtures :users
+
+ before do
+ @user = users(:bob_smith_user)
+
+ @uploadedfile = File.open(file_fixture_name("parrot.png"))
+ @uploadedfile.stub!(:original_filename).and_return('parrot.png')
+ end
it "should not let you change profile photo if you're not logged in as the user" do
- user = users(:bob_smith_user)
- data = load_file_fixture("parrot.png")
- post :profile_photo, { :id => user.id, :file => data }
+ post :profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_profile_photo => 1 }
end
it "should let you change profile photo if you're logged in as the user" do
- user = users(:bob_smith_user)
- user.profile_photo.should be_nil
+ @user.profile_photo.should be_nil
+ session[:user_id] = @user.id
- session[:user_id] = user.id
- tempfile = File.open(file_fixture_name("parrot.png"))
- tempfile.stub!(:original_filename).and_return('parrot.png')
- post :profile_photo, { :id => user.id, :file => tempfile, :submitted_profile_photo => 1 }
+ post :profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_profile_photo => 1 }
response.should redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith")
flash[:notice].should match(/Thank you for updating your profile photo/)