Sha256: bb85d584304009f461c4957e69ac968d8f7103ef44e2301425a6167f43e58ce3

Contents?: true

Size: 1.86 KB

Versions: 26

Compression:

Stored size: 1.86 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]) }
    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) { problem.assignment_for(user).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

26 entries across 26 versions & 1 rubygems

Version Path
mumuki-laboratory-6.4.2 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.4.1 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.4.0 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.2.0 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.1.5 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.0.4 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.1.4 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.1.3 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.0.3 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.1.2 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.1.1 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.1.0 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.0.2 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.0.1 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-6.0.0 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-5.13.0 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-5.12.1 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-5.12.0 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-5.11.0 spec/controllers/exercise_solutions_controller_spec.rb
mumuki-laboratory-5.10.4 spec/controllers/exercise_solutions_controller_spec.rb