Sha256: 2ec3a8e10538739712c5b777c11e4f9c5f097e8edb46ca8422354c375b57cd2a

Contents?: true

Size: 1.66 KB

Versions: 24

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

feature 'Guide Reset Flow', organization_workspace: :test do
  let(:user) { create(:user) }

  let!(:problem) { build(:problem) }

  let!(:lesson) { create(:lesson, description: 'An awesome guide', exercises: [problem]) }

  let!(:chapter) { create(:chapter, lessons: [lesson]) }

  let(:exam_problem) { build(:problem) }
  let(:test_organization) { Organization.find_by_name('test') }
  let(:exam) { create(:exam, organization: test_organization, guide: guide) }
  let(:guide) { create(:guide, exercises: [exam_problem])}

  before { exam.index_usage! test_organization }

  before { reindex_current_organization! }

  let(:restart_xpath) { "//i[@title='#{I18n.t(:restart)}']" }

  context 'no logged in user' do
    scenario 'visit guide' do
      visit "/lessons/#{lesson.id}"

      expect(page).to have_text('An awesome guide')
      expect(page).to_not have_xpath(restart_xpath)
    end
  end

  context 'logged in user' do
    before { set_current_user! user }

    scenario 'visit guide with no solutions sent for it' do
      visit "/lessons/#{lesson.id}"

      expect(page).to have_text('An awesome guide')
      expect(page).to_not have_xpath(restart_xpath)
    end

    scenario 'visit guide with solutions sent for it', :xpath_no_matches do
      problem.submit_solution! user

      visit "/lessons/#{lesson.id}"

      expect(page).to have_text('An awesome guide')
      expect(page).to have_xpath(restart_xpath)
    end

    scenario 'visit exam guide with solutions sent for it' do
      exam_problem.submit_solution! user
      exam.authorize!(user)

      visit "/exams/#{exam.id}"

      expect(page).to_not have_xpath(restart_xpath)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
mumuki-laboratory-9.0.6 spec/features/guide_reset_spec.rb
mumuki-laboratory-9.0.5 spec/features/guide_reset_spec.rb
mumuki-laboratory-9.0.4 spec/features/guide_reset_spec.rb
mumuki-laboratory-9.0.3 spec/features/guide_reset_spec.rb
mumuki-laboratory-9.0.2 spec/features/guide_reset_spec.rb
mumuki-laboratory-9.0.1 spec/features/guide_reset_spec.rb
mumuki-laboratory-9.0.0 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.6.1 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.6.0 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.5.0 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.4.0 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.3.0 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.2.1 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.2.0 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.1.3 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.1.2 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.1.1 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.1.0 spec/features/guide_reset_spec.rb
mumuki-laboratory-7.12.3 spec/features/guide_reset_spec.rb
mumuki-laboratory-8.0.0 spec/features/guide_reset_spec.rb