From b5bea7f14dfd23e27c42b1c7dafd48568cf0efd1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 28 Oct 2010 16:13:04 -0700 Subject: [PATCH] Add specs for photo mass assignment --- spec/controllers/photos_controller_spec.rb | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 spec/controllers/photos_controller_spec.rb diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb new file mode 100644 index 000000000..90bc9c183 --- /dev/null +++ b/spec/controllers/photos_controller_spec.rb @@ -0,0 +1,38 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe PhotosController do + render_views + before do + @user = Factory.create(:user) + @aspect = @user.aspect(:name => "lame-os") + @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' + @fixture_filename = 'button.png' + @fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename) + image = File.open(@fixture_name) + #@photo = Photo.instantiate( + # :person => @user.person, :album => @album, :user_file => image) + @photo = @user.post(:photo, :album_id => @album.id, :user_file => image, :to => @aspect.id) + sign_in :user, @user + end + + describe '#create' do + end + + describe "#update" do + it "should update the caption of a photo" do + put :update, :id => @photo.id, :photo => { :caption => "now with lasers!"} + @photo.reload.caption.should == "now with lasers!" + end + + it "doesn't overwrite random attributes" do + new_user = Factory.create :user + params = { :caption => "now with lasers!", :person_id => new_user.id} + put('update', :id => @photo.id, :photo => params) + @photo.reload.person_id.should == @user.person.id + end + end +end