poll_participation_spec no longer fails, added poll_participation factory
This commit is contained in:
parent
fe67bdf2e7
commit
5d560609e4
3 changed files with 41 additions and 24 deletions
|
|
@ -6,10 +6,7 @@ class Poll < ActiveRecord::Base
|
|||
has_many :poll_answers
|
||||
has_many :poll_participations
|
||||
|
||||
delegate :author, :author_id, :subscribers, to: :status_message
|
||||
#forward some requests to status message, because a poll is just attached to a status message and is not sharable itself
|
||||
delegate :author, :author_id, :public?, :subscribers, to: :status_message
|
||||
|
||||
#forward subscribers request to status message, because a poll is just attached to a status message and is not sharable itself
|
||||
#def subscribers(user)
|
||||
# status_message.subscribers(user)
|
||||
#end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -92,6 +92,12 @@ FactoryGirl.define do
|
|||
end
|
||||
end
|
||||
|
||||
factory(:status_message_with_poll, :parent => :status_message) do
|
||||
after(:build) do |sm|
|
||||
FactoryGirl.create(:poll, :status_message => sm)
|
||||
end
|
||||
end
|
||||
|
||||
factory(:status_message_with_photo, :parent => :status_message) do
|
||||
sequence(:text) { |n| "There are #{n} ninjas in this photo." }
|
||||
after(:build) do |sm|
|
||||
|
|
@ -107,6 +113,17 @@ FactoryGirl.define do
|
|||
end
|
||||
end
|
||||
|
||||
factory(:poll) do
|
||||
sequence(:question) { |n| "What do you think about #{n} ninjas?" }
|
||||
after(:build) do |p|
|
||||
FactoryGirl.create(:poll_answer, :poll => p)
|
||||
end
|
||||
end
|
||||
|
||||
factory(:poll_answer) do
|
||||
sequence(:answer) { |n| "#{n} questionmarks" }
|
||||
end
|
||||
|
||||
factory(:photo) do
|
||||
sequence(:random_string) {|n| SecureRandom.hex(10) }
|
||||
association :author, :factory => :person
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ describe PollParticipation do
|
|||
before do
|
||||
@alices_aspect = alice.aspects.first
|
||||
@status = bob.post(:status_message, :text => "hello", :to => bob.aspects.first.id)
|
||||
@poll = Poll.new(:question => 'Who is in charge?')
|
||||
@poll.poll_answers.build(:answer => "a")
|
||||
@poll.poll_answers.build(:answer => "b")
|
||||
@status.poll = @poll
|
||||
end
|
||||
|
||||
describe 'xml' do
|
||||
|
|
@ -53,26 +57,25 @@ describe PollParticipation do
|
|||
end
|
||||
end
|
||||
|
||||
# describe 'it is relayable' do
|
||||
# before do
|
||||
# @poll = Poll.new
|
||||
# @poll_answer = PollAnswer.new(:answer => '1')
|
||||
# @poll_answer2 = PollAnswer.new(:answer => '1')
|
||||
# @poll.answers << [poll_answer, poll_answer2]
|
||||
# @status.poll = @poll
|
||||
describe 'it is relayable' do
|
||||
before do
|
||||
@local_luke, @local_leia, @remote_raphael = set_up_friends
|
||||
@remote_parent = FactoryGirl.build(:status_message_with_poll, :author => @remote_raphael)
|
||||
|
||||
# @local_luke, @local_leia, @remote_raphael = set_up_friends
|
||||
# @remote_parent = FactoryGirl.build(:status_message, :author => @remote_raphael)
|
||||
# @local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first
|
||||
@local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first
|
||||
@poll2 = Poll.new(:question => 'Who is now in charge?')
|
||||
@poll2.poll_answers.build(:answer => "a")
|
||||
@poll2.poll_answers.build(:answer => "b")
|
||||
@local_parent.poll = @poll2
|
||||
|
||||
# @object_by_parent_author = @local_luke.vote!(@local_parent, @poll_answer)
|
||||
# @object_by_recipient = @local_leia.vote!(@local_parent, @poll_answer)
|
||||
# @dup_object_by_parent_author = @object_by_parent_author.dup
|
||||
@object_by_parent_author = @local_luke.participate_in_poll!(@local_parent, @poll.poll_answers.first)
|
||||
@object_by_recipient = @local_leia.participate_in_poll!(@local_parent, @poll.poll_answers.first)
|
||||
@dup_object_by_parent_author = @object_by_parent_author.dup
|
||||
|
||||
# @object_on_remote_parent = @local_luke.comment!(@remote_parent, "Yeah, it was great")
|
||||
# end
|
||||
|
||||
# let(:build_object) { alice.build_poll_participation(:poll => @poll, :poll_answer => @poll_answer) }
|
||||
# it_should_behave_like 'it is relayable'
|
||||
# end
|
||||
@object_on_remote_parent = @local_luke.participate_in_poll!(@remote_parent, @poll.poll_answers.first)
|
||||
end
|
||||
|
||||
let(:build_object) { PollParticipation::Generator.new(alice, @status, @poll.poll_answers.first).build }
|
||||
it_should_behave_like 'it is relayable'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue