Sha256: 343206548a1eff97389148e5d63c50fd6534bb9bb8bfe2a1c0a3559630465912

Contents?: true

Size: 1.73 KB

Versions: 26

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

feature 'public org', organization_workspace: :test do
  let!(:exercise) { build(:exercise) }
  let(:guide) { create(:guide) }
  let(:exam) { create(:exam) }
  let!(:chapter) {
    create(:chapter, lessons: [
      create(:lesson, guide: guide)]) }
  let(:book) { Organization.current.book }

  before { reindex_current_organization! }

  context 'anonymous visitor' do
    scenario 'from outside' do
      Capybara.current_session.driver.header 'Referer', 'http://google.com'

      visit '/'

      expect(page).to have_text('ム mumuki')
      expect(page).to have_text(Organization.current.book.name)
      expect(page).not_to have_text('Exams')
    end

    scenario 'from inside' do
      Capybara.current_session.driver.header 'Referer', 'http://en.mumuki.io/exercises/1'

      visit '/'

      expect(page).to have_text('ム mumuki')
      expect(page).to have_text(Organization.current.book.name)
    end
  end

  context 'logged visitor' do
    let(:user) { create(:user) }
    before { set_current_user! user }
    before { exam.authorize! user }

    scenario 'from outside' do
      Capybara.current_session.driver.header 'Referer', 'http://google.com'

      visit '/'

      expect(page).to have_text('ム mumuki')
      expect(page).to have_text(Organization.current.book.name)
      expect(user.reload.last_organization).to eq Organization.current
      expect(page).to have_text('Exams')
    end

    scenario 'from inside' do
      Capybara.current_session.driver.header 'Referer', 'http://en.mumuki.io/exercises/1'

      visit '/'

      expect(page).to have_text('ム mumuki')
      expect(page).to have_text(Organization.current.book.name)
      expect(user.reload.last_organization).to eq Organization.current
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
mumuki-laboratory-5.4.0 spec/features/home_public_flow_spec.rb
mumuki-laboratory-5.3.0 spec/features/home_public_flow_spec.rb
mumuki-laboratory-5.2.1 spec/features/home_public_flow_spec.rb
mumuki-laboratory-5.2.0 spec/features/home_public_flow_spec.rb
mumuki-laboratory-5.1.1 spec/features/home_public_flow_spec.rb
mumuki-laboratory-5.1.0 spec/features/home_public_flow_spec.rb