DEV: add a spec for "accept invite" log_on_user behaviour

This commit is contained in:
Arpit Jalan 2019-01-08 12:40:20 +05:30
parent 3457395f75
commit 05c015d252
1 changed files with 8 additions and 2 deletions

View File

@ -335,7 +335,10 @@ describe InvitesController do
before { invite.update_column(:via_email, true) }
it "doesn't send an activation email and activates the user" do
put "/invites/show/#{invite.invite_key}.json", params: { password: "verystrongpassword" }
expect do
put "/invites/show/#{invite.invite_key}.json", params: { password: "verystrongpassword" }
end.to change { UserAuthToken.count }.by(1)
expect(response.status).to eq(200)
expect(JSON.parse(response.body)["success"]).to eq(true)
@ -352,7 +355,10 @@ describe InvitesController do
before { invite.update_column(:via_email, false) }
it "sends an activation email and doesn't activate the user" do
put "/invites/show/#{invite.invite_key}.json", params: { password: "verystrongpassword" }
expect do
put "/invites/show/#{invite.invite_key}.json", params: { password: "verystrongpassword" }
end.not_to change { UserAuthToken.count }
expect(response.status).to eq(200)
expect(JSON.parse(response.body)["success"]).to eq(true)
expect(JSON.parse(response.body)["message"]).to eq(I18n.t("invite.confirm_email"))