Advertisement
Guest User

Untitled

a guest
May 24th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe Objective do
  4. describe '#locked?' do
  5. let(:objective) do
  6. described_class.new(locked_by: locked_by, lock_status: lock_status)
  7. end
  8.  
  9. context 'with prescribed status and locked_by' do
  10. let(:locked_by) { 'Bla' }
  11. let(:lock_status) { 1 }
  12.  
  13. it { expect(objective.locked?).to be true }
  14. end
  15.  
  16. context 'with wrong status and locked_by' do
  17. let(:locked_by) { 'Bla' }
  18. let(:lock_status) { 0 }
  19.  
  20. it { expect(objective.locked?).to be false }
  21. end
  22.  
  23. context 'with prescribed status and blank locked_by' do
  24. let(:locked_by) { '' }
  25. let(:lock_status) { 1 }
  26.  
  27. it { expect(objective.locked?).to be false }
  28. end
  29. end
  30.  
  31. describe '#release_lock'
  32. let(:objective) do
  33. described_class.new
  34. locked_by: 'a',
  35. lock_status: 'b',
  36. locked_on_name: 'c',
  37. locked_on_id: 1
  38. end
  39.  
  40. it 'assignes locked_by' do
  41. expect { objective.release_lock }.to change { objective.locked_by }.to nil
  42. end
  43.  
  44. it 'assignes locked_on_name' do
  45. expect { objective.release_lock }.to change { objective.locked_on_name }.to nil
  46. end
  47.  
  48. it 'assignes locked_on_id' do
  49. expect { objective.release_lock }.to change { objective.locked_on_id }.to nil
  50. end
  51.  
  52. it 'assignes lock_status' do
  53. expect { objective.lock_status }.to change { objective.locked_on_id }.to 0
  54. end
  55. end
  56. end
  57.  
  58. ############################################################
  59.  
  60. describe FindingAction do
  61. describe 'relations' do
  62. it { is_expected.to belong_to(:creator) }
  63. end
  64.  
  65. describe '#notify_creator' do
  66. before do
  67. described_class.stub(:send_creator_notification)
  68.  
  69. subject.notify_creator
  70. end
  71.  
  72. context 'when we should notificate creator' do
  73. before do
  74. described_class.stub(:should_notify_creator?) { true }
  75. end
  76.  
  77. it 'sends notification' do
  78. expect(subject).to have_received(:send_creator_notification).with(subject)
  79. end
  80. end
  81.  
  82. context 'when we should not notificate creator' do
  83. before do
  84. described_class.stub(:should_notify_creator?) { false }
  85. end
  86.  
  87. it 'does not send notification' do
  88. expect(subject).to_not have_received(:send_creator_notification)
  89. end
  90. end
  91. end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement