Sha256: b7cc55bf9c15df65addf17f7808d16519df0462dee3a552af3414df1574abc88

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require 'test_helper'

class LocaleTest < ActiveSupport::IntegrationCase

  teardown do
    Capybara.reset_sessions!
  end

  test 'before_sign_in flash' do
    visit new_article_path
    within '.flash' do
      assert page.has_content?('Please sign in first.')
    end
  end

  test 'after_sign_in flash' do
    user_factory 'Bob', 'bob', 'secret'
    sign_in_as 'bob', 'secret'
    within '.flash' do
      assert page.has_content?('You have successfully signed in.')
    end
  end

  test 'failed_sign_in flash' do
    sign_in_as 'bob', 'secret'
    within '.flash' do
      assert page.has_content?('Sorry, we did not recognise you.')
    end
  end

  test 'sign_out flash' do
    visit sign_out_path
    within '.flash' do
      assert page.has_content?('You have successfully signed out.')
    end
  end

  test 'before_sign_in flash is optional' do
    begin
      I18n.backend.store_translations :en, {:quo_vadis => {:flash => {:before_sign_in => ''}}}
      visit new_article_path
      assert page.has_no_css?('div.flash')
    ensure
      I18n.reload!
    end
  end

  test 'after_sign_in flash is optional' do
    user_factory 'Bob', 'bob', 'secret'
    begin
      I18n.backend.store_translations :en, {:quo_vadis => {:flash => {:after_sign_in => ''}}}
      sign_in_as 'bob', 'secret'
      assert page.has_no_css?('div.flash')
    ensure
      I18n.reload!
    end
  end

  test 'failed_sign_in flash is optional' do
    begin
      I18n.backend.store_translations :en, {:quo_vadis => {:flash => {:failed_sign_in => ''}}}
      sign_in_as 'bob', 'secret'
      assert page.has_no_css?('div.flash')
    ensure
      I18n.reload!
    end
  end

  test 'sign_out flash is optional' do
    begin
      I18n.backend.store_translations :en, {:quo_vadis => {:flash => {:sign_out => ''}}}
      visit sign_out_path
      assert page.has_no_css?('div.flash')
    ensure
      I18n.reload!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quo_vadis-1.0.1 test/integration/locale_test.rb