Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper'
- describe Objective do
- describe '#locked?' do
- let(:objective) do
- described_class.new(locked_by: locked_by, lock_status: lock_status)
- end
- context 'with prescribed status and locked_by' do
- let(:locked_by) { 'Bla' }
- let(:lock_status) { 1 }
- it { expect(objective.locked?).to be true }
- end
- context 'with wrong status and locked_by' do
- let(:locked_by) { 'Bla' }
- let(:lock_status) { 0 }
- it { expect(objective.locked?).to be false }
- end
- context 'with prescribed status and blank locked_by' do
- let(:locked_by) { '' }
- let(:lock_status) { 1 }
- it { expect(objective.locked?).to be false }
- end
- end
- describe '#release_lock'
- let(:objective) do
- described_class.new
- locked_by: 'a',
- lock_status: 'b',
- locked_on_name: 'c',
- locked_on_id: 1
- end
- it 'assignes locked_by' do
- expect { objective.release_lock }.to change { objective.locked_by }.to nil
- end
- it 'assignes locked_on_name' do
- expect { objective.release_lock }.to change { objective.locked_on_name }.to nil
- end
- it 'assignes locked_on_id' do
- expect { objective.release_lock }.to change { objective.locked_on_id }.to nil
- end
- it 'assignes lock_status' do
- expect { objective.lock_status }.to change { objective.locked_on_id }.to 0
- end
- end
- end
- ############################################################
- describe FindingAction do
- describe 'relations' do
- it { is_expected.to belong_to(:creator) }
- end
- describe '#notify_creator' do
- before do
- described_class.stub(:send_creator_notification)
- subject.notify_creator
- end
- context 'when we should notificate creator' do
- before do
- described_class.stub(:should_notify_creator?) { true }
- end
- it 'sends notification' do
- expect(subject).to have_received(:send_creator_notification).with(subject)
- end
- end
- context 'when we should not notificate creator' do
- before do
- described_class.stub(:should_notify_creator?) { false }
- end
- it 'does not send notification' do
- expect(subject).to_not have_received(:send_creator_notification)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement