fixed the build. made photos dependent destroy with parent status message
This commit is contained in:
parent
cc3db3d2f3
commit
a415ff5c5f
3 changed files with 15 additions and 8 deletions
|
|
@ -12,7 +12,7 @@ class StatusMessage < Post
|
||||||
xml_reader :message
|
xml_reader :message
|
||||||
|
|
||||||
key :message, String
|
key :message, String
|
||||||
many :photos, :class => Photo, :foreign_key => :status_message_id
|
many :photos, :class => Photo, :foreign_key => :status_message_id, :dependent => :destroy
|
||||||
validate :message_or_photos_present?
|
validate :message_or_photos_present?
|
||||||
|
|
||||||
attr_accessible :message
|
attr_accessible :message
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,10 @@ describe PublicsController do
|
||||||
describe '#receive' do
|
describe '#receive' do
|
||||||
let(:xml) { "<walruses></walruses>" }
|
let(:xml) { "<walruses></walruses>" }
|
||||||
context 'success cases' do
|
context 'success cases' do
|
||||||
it 'should 200 on successful receipt of a request' do
|
it 'should 200 on successful receipt of a request, and queues a job' do
|
||||||
post :receive, :id =>user.person.id, :xml => xml
|
|
||||||
response.code.should == '200'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'enqueues a receive job' do
|
|
||||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, xml).once
|
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, xml).once
|
||||||
post :receive, :id =>user.person.id, :xml => xml
|
post :receive, :id =>user.person.id, :xml => xml
|
||||||
|
response.code.should == '200'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,6 @@ describe Photo do
|
||||||
it 'should set the remote_photo on marshalling' do
|
it 'should set the remote_photo on marshalling' do
|
||||||
@photo.image.store! File.open(@fixture_name)
|
@photo.image.store! File.open(@fixture_name)
|
||||||
|
|
||||||
|
|
||||||
#security hax
|
#security hax
|
||||||
user2 = Factory.create(:user)
|
user2 = Factory.create(:user)
|
||||||
aspect2 = user2.aspects.create(:name => "foobars")
|
aspect2 = user2.aspects.create(:name => "foobars")
|
||||||
|
|
@ -157,4 +156,16 @@ describe Photo do
|
||||||
proc{ @user.comment("big willy style", :on => @photo) }.should change(@photo.comments, :count).by(1)
|
proc{ @user.comment("big willy style", :on => @photo) }.should change(@photo.comments, :count).by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "deletion" do
|
||||||
|
it 'is deleted with parent status message' do
|
||||||
|
status_message = @user.build_post(:status_message, :message => "whattup", :to => @aspect.id)
|
||||||
|
status_message.photos << @photo2
|
||||||
|
status_message.save
|
||||||
|
|
||||||
|
proc {
|
||||||
|
status_message.destroy
|
||||||
|
}.should change(Photo, :count).by(-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue