Sha256: f1048f1f46a16ca7054c1eea1c6e9f25435f152e797691024dcc2aee30e3bda3

Contents?: true

Size: 1.9 KB

Versions: 13

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

describe ExerciseSolutionsController, organization_workspace: :test do
  let(:user) { create(:user) }
  let(:problem) { create(:problem) }

  let!(:chapter) {
    create(:chapter, name: 'Functional Programming', lessons: [
      create(:lesson, exercises: [problem])
    ]) }

  before { reindex_current_organization! }
  before { set_current_user! user }

  context 'when simple content is sent' do
    before { post :create, params: { exercise_id: problem.id, solution: { content: 'asd' } } }

    it { expect(response.status).to eq 200 }
    it { expect(response.body).to json_eq(
                                    {status: :failed, guide_finished_by_solution: false},
                                    except: [:class_for_progress_list_item,
                                             :html, :title_html, :button_html,
                                             :expectations_html, :remaining_attempts_html,
                                             :test_results]) }
    it { expect(Assignment.last.solution).to eq('asd')}
  end

  context 'when multifile content is sent' do
    before { create(:language, extension: 'js', highlight_mode: 'javascript') }
    before { post :create, params: { exercise_id: problem.id, solution: { content: {
      'a_file.css' => 'a css content',
      'a_file.js' => 'a js content'
    } } } }
    let(:files) { Assignment.last.files }

    it { expect(response.status).to eq 200 }
    it { expect(Assignment.last.solution).to eq("/*<a_file.css#*/a css content/*#a_file.css>*/\n/*<a_file.js#*/a js content/*#a_file.js>*/") }
    it { expect(files.count).to eq 2 }
    it { expect(files[0]).to have_attributes(name: 'a_file.css', content: 'a css content') }
    it { expect(files[0].highlight_mode).to eq 'css' }
    it { expect(files[1]).to have_attributes(name: 'a_file.js', content: 'a js content') }
    it { expect(files[1].highlight_mode).to eq 'javascript' }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mumuki-laboratory-7.0.12 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.11 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.10 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.9 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.8 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.7 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.6 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.5 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.4 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.3 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.2 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.1 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-7.0.0 spec/controllers/exercise_solutions_controller_spec.rb