1
0
Fork 0

Add more specs

This commit is contained in:
Alex Kotov 2018-11-30 14:27:33 +05:00
parent df261cc930
commit 9d0d851d11
No known key found for this signature in database
GPG key ID: 4E831250F47DE154
2 changed files with 39 additions and 0 deletions

View file

@ -32,4 +32,8 @@ FactoryBot.define do
)
end
end
factory :confirmed_passport, parent: :passport do
confirmed { true }
end
end

View file

@ -112,4 +112,39 @@ RSpec.describe 'POST /passports/:passport_id/passport_confirmations' do
end
end
end
context 'when passport is already confirmed' do
let!(:passport) { create :confirmed_passport }
let(:current_user) { create :user }
before do
sign_in current_user
end
specify do
expect { make_request }.to \
change(PassportConfirmation, :count).from(0).to(1)
end
specify do
expect { make_request }.not_to \
change { passport.reload.confirmed? }.from(true)
end
context 'after request' do
before { make_request }
specify do
expect(response).to redirect_to passport
end
specify do
expect(PassportConfirmation.last).to have_attributes(
passport: passport,
user: current_user,
)
end
end
end
end