Commit dad7308c authored by Mario Manno's avatar Mario Manno

add sign_in helper to integration tests

parent 20ed6a34
......@@ -6,7 +6,6 @@ class RecentChangesTest < ActionDispatch::IntegrationTest
@conference = create(:conference)
@user = create(:user, person: create(:person), role: "admin")
@tmp_user = create(:user, person: create(:person), role: "admin")
post "/session", user: {email: @user.email, password: "frab23"}
end
teardown do
......@@ -14,8 +13,10 @@ class RecentChangesTest < ActionDispatch::IntegrationTest
end
test "home page still displays after event with person has been deleted" do
sign_in(@user)
assert_response :redirect
event = create(:event, conference: @conference)
event_person = create(:event_person, event: event)
create(:event_person, event: event)
PaperTrail.enabled = true
assert_difference "Event.count", -1 do
delete "/#{@conference.acronym}/events/#{event.id}"
......@@ -25,12 +26,13 @@ class RecentChangesTest < ActionDispatch::IntegrationTest
end
test "home page still displays after initiator of change has been deleted" do
sign_in(@tmp_user)
post "/session", user: {email: @tmp_user.email, password: "frab23"}
PaperTrail.enabled = true
event = create(:event, conference: @conference)
event_person = create(:event_person, event: event)
create(:event_person, event: event)
delete "/#{@conference.acronym}/people/#{@tmp_user.id}"
post "/session", user: {email: @user.email, password: "frab23"}
sign_in(@user)
get "/", conference_acronym: @conference.acronym
assert_response :success
end
......
......@@ -5,7 +5,7 @@ class SetEventPublicTest < ActionDispatch::IntegrationTest
@conference = create :three_day_conference
@event = create :event, conference: @conference
@conference_user = FactoryGirl.create :conference_orga, conference: @conference
post "/session", user: {email: @conference_user.user.email, password: "frab23"}
sign_in(@conference_user.user)
end
test "can set event to public" do
......
......@@ -15,7 +15,7 @@ class ActiveSupport::TestCase
def login_as(role)
user = FactoryGirl.create(
:user,
:user,
person: FactoryGirl.create(:person),
role: role.to_s
)
......@@ -23,4 +23,8 @@ class ActiveSupport::TestCase
user
end
def sign_in(user)
post "/session", user: { email: user.email, password: user.password }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment