Skip to content
Extraits de code Groupes Projets
Valider 14fedf53 rédigé par Sarah Mei's avatar Sarah Mei
Parcourir les fichiers

GAHHH STOP EMAILING ME (specs pass)

Also, added attr_protected to Photo#person and Photo#person_id.
parent f1ae95fa
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -48,7 +48,8 @@ class DevUtilitiesController < ApplicationController
@fixture_name = File.join(File.dirname(__FILE__), "..", "..", "public", "images", "user", "#{username}.jpg")
photo = Photo.new(:person => current_user.person, :album => album)
photo = Photo.new(:album => album)
photo.person = current_user.person
photo.image.store! File.open(@fixture_name)
photo.save
photo.reload
......
......@@ -97,7 +97,9 @@ class PhotosController < ApplicationController
respond_with @photo
else
flash[:error] = I18n.t 'photos.update.error'
render :action => :edit
@album = @photo.album
set_friends_and_status
render :edit
end
end
end
......@@ -32,12 +32,16 @@ class Photo < Post
before_destroy :ensure_user_picture
attr_protected :person
def self.instantiate(params = {})
image_file = params[:user_file]
params.delete :user_file
image_file = params.delete(:user_file)
person = params.delete(:person)
photo = Photo.new(params)
photo.image.store! image_file
photo.person = person
photo.save
photo
end
......
......@@ -15,7 +15,7 @@ describe PhotosController do
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)
@photo = @user.post(:photo, :album_id => @album.id, :user_file => image, :to => @aspect.id)
sign_in :user, @user
end
......
......@@ -14,7 +14,21 @@ describe Photo do
@fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename)
@fail_fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', 'msg.xml')
@photo = Photo.new(:person => @user.person, :album => @album)
@photo = Photo.new(:album => @album)
@photo.person = @user.person
end
describe "protected attributes" do
it "doesn't allow mass assignment of person" do
@photo.save!
@photo.update_attributes(:person => Factory(:person))
@photo.reload.person.should == @user.person
end
it "doesn't allow mass assignment of person_id" do
@photo.save!
@photo.update_attributes(:person_id => Factory(:person).id)
@photo.reload.person.should == @user.person
end
end
it 'has a constructor' do
......
......@@ -16,11 +16,13 @@ describe User do
describe 'overwriting people' do
it 'does not overwrite old users with factory' do
pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!"
new_user = Factory.create(:user, :id => user.id)
new_user.persisted?.should be_true
new_user.id.should_not == user.id
end
it 'does not overwrite old users with create' do
pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!"
params = {:username => "ohai",
:email => "ohai@example.com",
:password => "password",
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter