<commit_before>require 'spec_helper'

feature 'menu bar' do
  let(:chapter) { create(:chapter, lessons: [create(:lesson)]) }
  let(:book) { create(:book, chapters: [chapter], name: 'private', slug: 'mumuki/mumuki-the-private-book') }
  let(:private_organization) { create(:organization, name: 'private', book: book) }

  before { set_subdomain_host! private_organization.name }
  before { private_organization.switch! }

  context 'anonymous user' do
    scenario 'should not see any app' do
      visit '/'

      expect(page).not_to have_text('Classroom')
      expect(page).not_to have_text('Bibliotheca')
    end
  end

  context 'logged user' do
    let(:visitor) { create(:user) }
    let(:student) { create(:user, permissions: {student: 'private/*'}) }
    let(:teacher) { create(:user, permissions: {student: 'private/*', teacher: 'private/*'}) }
    let(:writer) { create(:user, permissions: {student: 'private/*', writer: 'private/*'}) }
    let(:janitor) { create(:user, permissions: {student: 'private/*', janitor: 'private/*'}) }
    let(:owner) { create(:user, permissions: {student: 'private/*', owner: 'private/*'}) }

    scenario 'visitor should not see any app' do
      set_current_user! visitor

      visit '/'
      expect(page).not_to have_text('Classroom')
      expect(page).not_to have_text('Bibliotheca')
    end

    scenario 'teacher should see classroom' do
      set_current_user! teacher

      visit '/'

      expect(page).to have_text('Classroom')
      expect(page).not_to have_text('Bibliotheca')
    end

    scenario 'writer should see bibliotheca' do
      set_current_user! writer

      visit '/'

      expect(page).not_to have_text('Classroom')
      expect(page).to have_text('Bibliotheca')
    end
  end
end
<commit_msg>Add menu bar test cases for unlogged users<commit_after>require 'spec_helper'

feature 'menu bar' do
  let(:chapter) { create(:chapter, lessons: [create(:lesson)]) }
  let(:book) { create(:book, chapters: [chapter], name: 'private', slug: 'mumuki/mumuki-the-private-book') }
  let(:private_organization) { create(:organization, name: 'private', book: book) }

  before { set_subdomain_host! private_organization.name }
  before { private_organization.switch! }

  context 'anonymous user' do
    context 'on organization without permissions' do
      scenario 'should not see menu bar' do
        OmniAuth.config.test_mode = false

        visit '/'

        expect(page).not_to have_text('Profile')
        expect(page).not_to have_text('Classroom')
        expect(page).not_to have_text('Bibliotheca')
      end
    end

    context 'on organization with permissions' do
      let(:public_organization) { create(:public_organization, book: book) }
      before { set_subdomain_host! public_organization.name }
      before { public_organization.switch! }

      scenario 'should not see menu bar' do
        OmniAuth.config.test_mode = false

        visit '/'

        expect(page).not_to have_text('Profile')
        expect(page).not_to have_text('Classroom')
        expect(page).not_to have_text('Bibliotheca')
      end
    end
  end

  context 'logged user' do
    let(:visitor) { create(:user) }
    let(:student) { create(:user, permissions: {student: 'private/*'}) }
    let(:teacher) { create(:user, permissions: {student: 'private/*', teacher: 'private/*'}) }
    let(:writer) { create(:user, permissions: {student: 'private/*', writer: 'private/*'}) }
    let(:janitor) { create(:user, permissions: {student: 'private/*', janitor: 'private/*'}) }
    let(:owner) { create(:user, permissions: {student: 'private/*', owner: 'private/*'}) }

    scenario 'visitor should not see any app' do
      set_current_user! visitor

      visit '/'
      expect(page).not_to have_text('Classroom')
      expect(page).not_to have_text('Bibliotheca')
    end

    scenario 'teacher should see classroom' do
      set_current_user! teacher

      visit '/'

      expect(page).to have_text('Classroom')
      expect(page).not_to have_text('Bibliotheca')
    end

    scenario 'writer should see bibliotheca' do
      set_current_user! writer

      visit '/'

      expect(page).not_to have_text('Classroom')
      expect(page).to have_text('Bibliotheca')
    end
  end
end

{'fraction_non_alphanumeric': 0.14080188679245284, 'fraction_numerical': 0.0, 'mean_word_length': 3.6451259583789706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '902533', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1297, 'n_words': 315}