Sha256: e908330d8a6c2f9bc69aa51d43672072bd186c47c6889bec62aa5cf0106c07a5

Contents?: true

Size: 1.02 KB

Versions: 28

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe DiscussionsController, organization_workspace: :test do
  let(:user) { create(:user) }
  let(:exercise) { create(:exercise) }
  let(:exercise_params) { {debatable_class: 'Exercise', exercise_id: exercise.id} }

  before { set_current_user! user }
  before { Organization.current.tap { |it| it.forum_enabled = true }.save! }

  describe 'post' do
    before { allow_any_instance_of(DiscussionsController).to receive(:discussion_params).and_return title: 'A title' }
    before { post :create, params: exercise_params }

    it { expect(response.status).to eq 302 }
    it { expect(exercise.discussions.size).to eq 1 }
    it { expect(user.discussions.size).to eq 1 }
    it { expect(user.watched_discussions.size).to eq 1 }

    describe 'deleting exercises does delete all discussions' do
      before { @discussion_id = exercise.discussions.first.id }
      before { exercise.destroy }

      it { expect { Discussion.find(@discussion_id) }.to raise_exception(ActiveRecord::RecordNotFound) }
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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