diff options
author | Francis Irving <francis@mysociety.org> | 2010-07-14 01:50:50 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-07-14 01:50:50 +0100 |
commit | 5972a15c7f781592f8757ba2799c5286d04dc771 (patch) | |
tree | 92715c423789f12d56166c123f61dd8cedae5429 /spec/controllers/user_controller_spec.rb | |
parent | 57de5cb0a4de67e196984d16f91d973df4aebc2d (diff) |
Some more tests for profile photos.
Diffstat (limited to 'spec/controllers/user_controller_spec.rb')
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 832ac718c..ff6ce2b56 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -462,6 +462,9 @@ describe UserController, "when using profile photos" do @uploadedfile = File.open(file_fixture_name("parrot.png")) @uploadedfile.stub!(:original_filename).and_return('parrot.png') + + @uploadedfile_2 = File.open(file_fixture_name("parrot.jpg")) + @uploadedfile_2.stub!(:original_filename).and_return('parrot.jpg') end it "should not let you change profile photo if you're not logged in as the user" do @@ -477,8 +480,24 @@ describe UserController, "when using profile photos" do response.should redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith") flash[:notice].should match(/Thank you for updating your profile photo/) - user.reload - user.profile_photo.should_not be_nil + @user.reload + @user.profile_photo.should_not be_nil + end + + it "should let you change profile photo twice" do + @user.profile_photo.should be_nil + session[:user_id] = @user.id + + 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/) + + post :profile_photo, { :id => @user.id, :file => @uploadedfile_2, :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/) + + @user.reload + @user.profile_photo.should_not be_nil end end |