I want to check that the create method creates and object with one
attribute set to a particular value. In this case I want to check:
assert_equal @p.user_type, 'MODERATOR'
The problem is that I am trying to load an object but it is always
nil. I tried that query in the console and it is ok. Is there
something that I am missing?
(I am using factory girl for the testing data)
-------------------------------------
Full code:
class ParticipationControllerTest < ActionController::TestCase
context "on POST to :create" do
setup do
@configuration_panel = Factory.create :configuration, :status =>
'PANEL'
@configuration_live = Factory.create :configuration,
:status => 'LIVE',
:panel_id =>
@
configuration_panel.id
@bernie = Factory.create :participant,
:name => 'Bernie X',
:email => '
ber...@email.com'
post :create, :participation => { :participant_id => @
bernie.id,
:configuration_id =>
@
configuration_live.id }
end
should assign_to :participation
should respond_with :success
@bernie = Participant.find_by_email '
ber...@email.com'
@p = Participation.find_by_participant_id @
bernie.id
# bernie is the first host so it should be automatically a
moderator
assert_equal @p.user_type, 'MODERATOR'
end
end