Created
July 30, 2014 08:01
-
-
Save davetoxa/8eacf9254d7a2fadd8a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Confirmations" do | |
subject { page } | |
login(:with_email) | |
it 'подтверждает пользователя' do | |
# залогиненный юзер заходит в личный кабинет | |
visit edit_cabinet_user_path | |
# нажимает на ссылку для повторной отправки кода | |
click_link I18n.t('cabinet.users.edit.resend_email_confirmation_instruction') | |
# получаем флеш "Письмо c инструкциями по подтверждению отправлено повторно" | |
should have_css('.flash.notice') | |
email = ActionMailer::Base.deliveries.last | |
confirm_path = users_confirmation_path(confirmation_token: current_user.reload.confirmation_token) | |
# находим письмо | |
email.body.raw_source.should include confirm_path | |
# нажимаем на подтверждение | |
visit confirm_path | |
# редирект, нотис | |
should have_css('.flash.notice') | |
# переходим в кабинет | |
visit edit_cabinet_user_path | |
# не видим ссылки на повторное подтверждение | |
should_not have_css('.alert.alert-error.resend_confirmation') | |
end | |
it 'не подтверждает пользователя с фейковым токеном' do | |
visit users_confirmation_path(confirmation_token: 'fake_token') | |
current_path.should eq root_path | |
should have_css('.flash.alert') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe 'PasswordsController', js: true do | |
subject { page } | |
let(:login_account) do | |
create :login_account, email: 'anton@gmail.com' | |
end | |
before do | |
login_account.user.confirm! | |
end | |
it 'восстанавливает аккаунт пользователя' do | |
visit root_path | |
find('.b-auth a.js-signin').trigger('click') | |
click_link I18n.t('users.sessions.new.forgot_password') | |
within '.login_account_email' do | |
fill_in :login_account_email, with: 'anton@gmail.com' | |
end | |
click_button I18n.t('devise.passwords.new.send_password_instructions') | |
page.should have_css('.flash.notice') | |
login_account.reload | |
recover_path = edit_login_account_password_path(reset_password_token: login_account.reset_password_token) | |
ActionMailer::Base.deliveries.last.body.raw_source.should include recover_path | |
visit recover_path | |
within '.new_login_account' do | |
fill_in :login_account_password, with: '12345678' | |
fill_in :login_account_password_confirmation, with: '12345678' | |
click_button I18n.t('devise.passwords.edit.change_password_button') | |
end | |
page.should have_css('.flash.notice') | |
visit root_path | |
page.should have_text(login_account.user.name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment