Sha256: e9945090066fa238de2beafa0418e8b0fe7efc50544af728f8b27177b73dd8b2

Contents?: true

Size: 862 Bytes

Versions: 13

Compression:

Stored size: 862 Bytes

Contents

require 'spec_helper'

describe MessagesController do
  let(:user) { create(:user) }
  let(:exercise) { create(:exercise) }
  before { set_current_user! user }
  before { allow_any_instance_of(MessagesController).to receive(:message_params).and_return content: 'foo' }

  describe 'post when no previous assignment' do
    before { post :create, params: {exercise_id: exercise.id} }

    it { expect(response.status).to eq 302 }
    it { expect(user.assignments.size).to eq 1 }
    it { expect(user.messages.size).to eq 1 }
  end

  describe 'post when previous assignment' do
    let(:assignment) { exercise.submit_solution!(user, content: '') }
    before { post :create, params: {exercise_id: exercise.id} }

    it { expect(response.status).to eq 302 }
    it { expect(user.assignments.size).to eq 1 }
    it { expect(user.messages.size).to eq 1 }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mumuki-laboratory-5.0.12 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.11 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.10 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.9 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.8 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.7 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.6 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.5 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.4 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.3 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.2 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.1 spec/controllers/messages_controller_spec.rb
mumuki-laboratory-5.0.0 spec/controllers/messages_controller_spec.rb