Skip to content

Commit 2100af7

Browse files
committed
add rspec to test confirm email flash on participant /show route
1 parent 5285181 commit 2100af7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

spec/controllers/participants_controller_spec.rb

+38
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,44 @@
5353
expect(response).to be_successful
5454
expect(assigns(:participant)).to be_kind_of Participant
5555
end
56+
57+
context "when logged in" do
58+
context "when logged in user has not confirmed email" do
59+
let(:unconfirmed_email_participant) { create(:participant, email_confirmed_at: nil )}
60+
61+
before do
62+
activate_authlogic
63+
ParticipantSession.create(unconfirmed_email_participant)
64+
end
65+
66+
it "should display confirm email flash message" do
67+
get :show, params: {id: participant}
68+
expect(flash[:alert]).to be_present
69+
end
70+
end
71+
end
72+
73+
context "when logged in user has confirmed email" do
74+
let(:unconfirmed_email_participant) { create(:participant, email_confirmed_at: Time.now )}
75+
76+
before do
77+
activate_authlogic
78+
ParticipantSession.create(unconfirmed_email_participant)
79+
end
80+
81+
it "should not display confirm email flash message" do
82+
get :show, params: {id: participant}
83+
expect(flash[:alert]).not_to be_present
84+
end
85+
end
86+
87+
88+
context "when not logged in" do
89+
it "should not show confirm email flash message" do
90+
get :show, params: {id: participant}
91+
expect(flash[:alert]).not_to be_present
92+
end
93+
end
5694
end
5795

5896
context "when the logged in user operates on someone elses record" do

0 commit comments

Comments
 (0)