contract_acceptance_framework 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,12 +11,12 @@ module ContractAcceptanceFramework
|
|
11
11
|
has_many :contracts, :through => :contract_acceptances
|
12
12
|
|
13
13
|
def has_agreed_to?(contract)
|
14
|
-
contracts.include?(contract)
|
14
|
+
contracts.find(:all).include?(contract)
|
15
15
|
end
|
16
16
|
|
17
17
|
def agree_to!(contract)
|
18
18
|
raise ContractDuplicateAgreementError if has_agreed_to?(contract)
|
19
|
-
contract_acceptances.create(:contract => contract)
|
19
|
+
contract_acceptances.create(:contract => contract, :acceptable => self)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe 'Contract Acceptance Framework' do
|
4
4
|
let(:person) { Person.create }
|
5
5
|
let(:contract) do
|
6
|
+
Contract.delete_all
|
6
7
|
Contract.create(:major_version => 0, :minor_version => 0,
|
7
8
|
:maintenance_version => 0, :key => 'unique string',
|
8
9
|
:content => 'content')
|
@@ -24,15 +25,17 @@ describe 'Contract Acceptance Framework' do
|
|
24
25
|
end
|
25
26
|
|
26
27
|
describe '.has_agreed_to?' do
|
27
|
-
subject { person.has_agreed_to?(contract) }
|
28
|
-
|
29
28
|
context 'when the contract has been agreed to' do
|
30
29
|
before { person.agree_to!(contract) }
|
31
|
-
it
|
30
|
+
it 'should be true' do
|
31
|
+
person.has_agreed_to?(contract).should be_true
|
32
|
+
end
|
32
33
|
end
|
33
34
|
|
34
35
|
context 'when the contract has not been agreed to' do
|
35
|
-
it
|
36
|
+
it 'should be false' do
|
37
|
+
person.has_agreed_to?(contract).should be_false
|
38
|
+
end
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
data/spec/spec_helper.rb
CHANGED