fine_print 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/Rakefile +0 -1
- data/app/assets/javascripts/fine_print/application.js +0 -1
- data/app/assets/stylesheets/fine_print/application.css +0 -1
- data/app/controllers/fine_print/application_controller.rb +9 -4
- data/app/controllers/fine_print/contracts_controller.rb +16 -12
- data/app/controllers/fine_print/home_controller.rb +5 -0
- data/app/controllers/fine_print/signatures_controller.rb +44 -2
- data/app/models/fine_print/contract.rb +17 -45
- data/app/models/fine_print/signature.rb +4 -3
- data/app/views/fine_print/contracts/_show.html.erb +11 -0
- data/app/views/fine_print/contracts/edit.html.erb +1 -1
- data/app/views/fine_print/contracts/index.html.erb +12 -14
- data/app/views/fine_print/contracts/new_version.html.erb +1 -1
- data/app/views/fine_print/contracts/show.html.erb +18 -29
- data/app/views/fine_print/signatures/_form.html.erb +21 -0
- data/app/views/fine_print/signatures/index.html.erb +3 -7
- data/app/views/fine_print/signatures/new.html.erb +13 -0
- data/config/initializers/fine_print.rb +36 -33
- data/config/routes.rb +5 -5
- data/db/migrate/0_install_fine_print.rb +2 -3
- data/lib/fine_print/controller_includes.rb +41 -67
- data/lib/fine_print/engine.rb +3 -0
- data/lib/fine_print/version.rb +1 -1
- data/lib/fine_print.rb +48 -57
- data/spec/controllers/contracts_controller_spec.rb +98 -98
- data/spec/controllers/home_controller_spec.rb +7 -5
- data/spec/controllers/signatures_controller_spec.rb +48 -19
- data/spec/dummy/app/models/dummy_user.rb +0 -1
- data/spec/dummy/config/initializers/fine_print.rb +2 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +31970 -0
- data/spec/dummy/log/test.log +71587 -0
- data/spec/lib/fine_print/controller_includes_spec.rb +9 -14
- data/spec/lib/fine_print_spec.rb +15 -9
- data/spec/models/contract_spec.rb +17 -25
- data/spec/models/signature_spec.rb +4 -14
- data/spec/spec_helper.rb +1 -2
- metadata +33 -4
- data/app/views/fine_print/home/index.html.erb +0 -16
- data/lib/fine_print/security_transgression.rb +0 -3
@@ -2,14 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module FinePrint
|
4
4
|
describe ControllerIncludes do
|
5
|
-
it 'must add
|
6
|
-
expect(ActionController::Base.new.respond_to? :
|
7
|
-
expect(DummyModelsController.new.respond_to? :
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'must add fine_print_redirect to ActionController instances' do
|
11
|
-
expect(ActionController::Base.new.respond_to? :fine_print_redirect).to eq true
|
12
|
-
expect(DummyModelsController.new.respond_to? :fine_print_redirect).to eq true
|
5
|
+
it 'must add fine_print_sign to ActionController instances' do
|
6
|
+
expect(ActionController::Base.new.respond_to? :fine_print_sign).to eq true
|
7
|
+
expect(DummyModelsController.new.respond_to? :fine_print_sign).to eq true
|
13
8
|
end
|
14
9
|
|
15
10
|
it 'must add fine_print_return to ActionController instances' do
|
@@ -17,14 +12,14 @@ module FinePrint
|
|
17
12
|
expect(DummyModelsController.new.respond_to?(:fine_print_return, true)).to eq true
|
18
13
|
end
|
19
14
|
|
20
|
-
it 'must add
|
21
|
-
expect(ActionController::Base.respond_to? :
|
22
|
-
expect(DummyModelsController.respond_to? :
|
15
|
+
it 'must add fine_print_require to ActionController and subclasses' do
|
16
|
+
expect(ActionController::Base.respond_to? :fine_print_require).to eq true
|
17
|
+
expect(DummyModelsController.respond_to? :fine_print_require).to eq true
|
23
18
|
end
|
24
19
|
|
25
|
-
it 'must add
|
26
|
-
expect(ActionController::Base.respond_to? :
|
27
|
-
expect(DummyModelsController.respond_to? :
|
20
|
+
it 'must add fine_print_skip to ActionController and subclasses' do
|
21
|
+
expect(ActionController::Base.respond_to? :fine_print_skip).to eq true
|
22
|
+
expect(DummyModelsController.respond_to? :fine_print_skip).to eq true
|
28
23
|
end
|
29
24
|
end
|
30
25
|
end
|
data/spec/lib/fine_print_spec.rb
CHANGED
@@ -5,11 +5,11 @@ describe FinePrint do
|
|
5
5
|
@alpha_1 = FactoryGirl.create(:published_contract, :name => 'alpha')
|
6
6
|
@beta_1 = FactoryGirl.create(:published_contract, :name => 'beta')
|
7
7
|
|
8
|
-
@user =
|
8
|
+
@user = DummyUser.create
|
9
9
|
@alpha_1_sig = FactoryGirl.create(:signature, :contract => @alpha_1, :user => @user)
|
10
10
|
@beta_1_sig = FactoryGirl.create(:signature, :contract => @beta_1, :user => @user)
|
11
11
|
|
12
|
-
@alpha_2 = @alpha_1.
|
12
|
+
@alpha_2 = @alpha_1.new_version
|
13
13
|
@alpha_2.update_attribute(:content, 'foo')
|
14
14
|
@alpha_2.publish
|
15
15
|
end
|
@@ -23,25 +23,31 @@ describe FinePrint do
|
|
23
23
|
expect(FinePrint.get_contract('alpha')).to eq @alpha_2
|
24
24
|
end
|
25
25
|
|
26
|
+
it 'gets signed contracts' do
|
27
|
+
expect(FinePrint.get_signed_contract_ids(@user)).to(
|
28
|
+
eq [@beta_1.id])
|
29
|
+
end
|
30
|
+
|
26
31
|
it 'gets unsigned contracts' do
|
27
|
-
expect(FinePrint.
|
32
|
+
expect(FinePrint.get_unsigned_contract_ids(@user, @alpha_2.id, @beta_1.id)).to(
|
33
|
+
eq [@alpha_2.id])
|
28
34
|
end
|
29
35
|
|
30
36
|
it 'allows users to sign contracts' do
|
31
37
|
expect(FinePrint.signed_contract?(@user, @alpha_1)).to eq true
|
32
38
|
expect(FinePrint.signed_contract?(@user, @alpha_2)).to eq false
|
33
39
|
expect(FinePrint.signed_contract?(@user, @beta_1)).to eq true
|
34
|
-
expect(FinePrint.
|
35
|
-
expect(FinePrint.
|
36
|
-
expect(FinePrint.
|
40
|
+
expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_1)).to eq true
|
41
|
+
expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_2)).to eq true
|
42
|
+
expect(FinePrint.signed_any_version_of_contract?(@user, @beta_1)).to eq true
|
37
43
|
|
38
44
|
expect(FinePrint.sign_contract(@user, @alpha_2)).to be_a FinePrint::Signature
|
39
45
|
|
40
46
|
expect(FinePrint.signed_contract?(@user, @alpha_1)).to eq true
|
41
47
|
expect(FinePrint.signed_contract?(@user, @alpha_2)).to eq true
|
42
48
|
expect(FinePrint.signed_contract?(@user, @beta_1)).to eq true
|
43
|
-
expect(FinePrint.
|
44
|
-
expect(FinePrint.
|
45
|
-
expect(FinePrint.
|
49
|
+
expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_1)).to eq true
|
50
|
+
expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_2)).to eq true
|
51
|
+
expect(FinePrint.signed_any_version_of_contract?(@user, @beta_1)).to eq true
|
46
52
|
end
|
47
53
|
end
|
@@ -4,12 +4,10 @@ module FinePrint
|
|
4
4
|
describe Contract do
|
5
5
|
it 'can be published and unpublished' do
|
6
6
|
contract = FactoryGirl.create(:contract)
|
7
|
-
expect(contract.is_published?).to
|
7
|
+
expect(contract.is_published?).to eq false
|
8
8
|
expect(contract.version).to be_nil
|
9
|
-
expect(contract.is_latest?).to
|
10
|
-
expect(contract.
|
11
|
-
expect(contract.can_be_published?).to be_true
|
12
|
-
expect(contract.can_be_unpublished?).to be_false
|
9
|
+
expect(contract.is_latest?).to eq false
|
10
|
+
expect(contract.signatures).to be_empty
|
13
11
|
|
14
12
|
contract.unpublish
|
15
13
|
expect(contract.errors).not_to be_empty
|
@@ -17,12 +15,10 @@ module FinePrint
|
|
17
15
|
expect(contract.errors).to be_empty
|
18
16
|
contract.publish
|
19
17
|
expect(contract.errors).to be_empty
|
20
|
-
expect(contract.is_published?).to
|
21
|
-
expect(contract.version).to
|
22
|
-
expect(contract.is_latest?).to
|
23
|
-
expect(contract.
|
24
|
-
expect(contract.can_be_published?).to be_false
|
25
|
-
expect(contract.can_be_unpublished?).to be_true
|
18
|
+
expect(contract.is_published?).to eq true
|
19
|
+
expect(contract.version).to eq 1
|
20
|
+
expect(contract.is_latest?).to eq true
|
21
|
+
expect(contract.signatures).to be_empty
|
26
22
|
|
27
23
|
contract.publish
|
28
24
|
expect(contract.errors).not_to be_empty
|
@@ -30,23 +26,19 @@ module FinePrint
|
|
30
26
|
expect(contract.errors).to be_empty
|
31
27
|
contract.unpublish
|
32
28
|
expect(contract.errors).to be_empty
|
33
|
-
expect(contract.is_published?).to
|
29
|
+
expect(contract.is_published?).to eq false
|
34
30
|
end
|
35
31
|
|
36
|
-
it "can't be modified after a user signs" do
|
32
|
+
it "can't be modified after a user signs it" do
|
37
33
|
contract = FactoryGirl.create(:contract)
|
38
34
|
|
39
35
|
contract.publish
|
40
|
-
expect(contract.is_published?).to
|
41
|
-
expect(contract.
|
42
|
-
expect(contract.can_be_published?).to be_false
|
43
|
-
expect(contract.can_be_unpublished?).to be_true
|
36
|
+
expect(contract.is_published?).to eq true
|
37
|
+
expect(contract.signatures).to be_empty
|
44
38
|
|
45
39
|
ua = FactoryGirl.create(:signature, :contract => contract)
|
46
40
|
contract.reload
|
47
|
-
expect(contract.
|
48
|
-
expect(contract.can_be_published?).to be_false
|
49
|
-
expect(contract.can_be_unpublished?).to be_false
|
41
|
+
expect(contract.signatures).not_to be_empty
|
50
42
|
|
51
43
|
contract.save
|
52
44
|
expect(contract.errors).not_to be_empty
|
@@ -54,14 +46,14 @@ module FinePrint
|
|
54
46
|
expect(contract.errors).to be_empty
|
55
47
|
contract.unpublish
|
56
48
|
expect(contract.errors).not_to be_empty
|
57
|
-
expect(contract.is_published?).to
|
49
|
+
expect(contract.reload.is_published?).to eq true
|
58
50
|
end
|
59
51
|
|
60
52
|
it 'results in a new version if a copy is published' do
|
61
53
|
contract = FactoryGirl.create(:published_contract)
|
62
54
|
expect(contract.version).to eq 1
|
63
|
-
new_version = contract.
|
64
|
-
expect(new_version.save).to
|
55
|
+
new_version = contract.new_version
|
56
|
+
expect(new_version.save).to eq true
|
65
57
|
new_version.publish
|
66
58
|
expect(new_version.version).to eq 2
|
67
59
|
end
|
@@ -69,9 +61,9 @@ module FinePrint
|
|
69
61
|
it 'results in a first version if a name is changed after publishing' do
|
70
62
|
contract = FactoryGirl.create(:published_contract)
|
71
63
|
expect(contract.version).to eq 1
|
72
|
-
new_version = contract.
|
64
|
+
new_version = contract.new_version
|
73
65
|
new_version.name = 'Joe'
|
74
|
-
expect(new_version.save).to
|
66
|
+
expect(new_version.save).to eq true
|
75
67
|
new_version.publish
|
76
68
|
expect(new_version.version).to eq 1
|
77
69
|
end
|
@@ -4,25 +4,15 @@ module FinePrint
|
|
4
4
|
describe Signature do
|
5
5
|
it 'can''t be associated with unpublished contracts' do
|
6
6
|
contract = FactoryGirl.create(:contract)
|
7
|
-
expect(contract.is_published?).to
|
8
|
-
expect(contract.
|
7
|
+
expect(contract.is_published?).to eq false
|
8
|
+
expect(contract.signatures).to be_empty
|
9
9
|
|
10
10
|
sig = FactoryGirl.build(:signature)
|
11
11
|
sig.contract = contract
|
12
|
-
expect(sig.save).to
|
12
|
+
expect(sig.save).to eq false
|
13
13
|
|
14
14
|
contract.reload
|
15
|
-
expect(contract.
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'prevents contract from being updated' do
|
19
|
-
sig = FactoryGirl.build(:signature)
|
20
|
-
contract = sig.contract
|
21
|
-
expect(contract.can_be_updated?).to be_true
|
22
|
-
|
23
|
-
sig.save!
|
24
|
-
contract.reload
|
25
|
-
expect(contract.can_be_updated?).to be_false
|
15
|
+
expect(contract.signatures).to be_empty
|
26
16
|
end
|
27
17
|
end
|
28
18
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,6 @@ ENV['RAILS_ENV'] ||= 'test'
|
|
2
2
|
|
3
3
|
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
4
4
|
require 'rspec/rails'
|
5
|
-
require 'rspec/autorun'
|
6
5
|
require 'factory_girl_rails'
|
7
6
|
require 'faker'
|
8
7
|
|
@@ -13,7 +12,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
13
12
|
|
14
13
|
RSpec.configure do |config|
|
15
14
|
config.mock_with :rspec
|
16
|
-
config.use_transactional_fixtures =
|
15
|
+
config.use_transactional_fixtures = false
|
17
16
|
config.infer_base_class_for_anonymous_controllers = false
|
18
17
|
config.order = 'random'
|
19
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fine_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -39,6 +39,34 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: action_interceptor
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.4.1
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: squeel
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
42
70
|
- !ruby/object:Gem::Dependency
|
43
71
|
name: sqlite3
|
44
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,13 +160,15 @@ files:
|
|
132
160
|
- app/models/fine_print/contract.rb
|
133
161
|
- app/models/fine_print/signature.rb
|
134
162
|
- app/views/fine_print/contracts/_form.html.erb
|
163
|
+
- app/views/fine_print/contracts/_show.html.erb
|
135
164
|
- app/views/fine_print/contracts/edit.html.erb
|
136
165
|
- app/views/fine_print/contracts/index.html.erb
|
137
166
|
- app/views/fine_print/contracts/new.html.erb
|
138
167
|
- app/views/fine_print/contracts/new_version.html.erb
|
139
168
|
- app/views/fine_print/contracts/show.html.erb
|
140
|
-
- app/views/fine_print/
|
169
|
+
- app/views/fine_print/signatures/_form.html.erb
|
141
170
|
- app/views/fine_print/signatures/index.html.erb
|
171
|
+
- app/views/fine_print/signatures/new.html.erb
|
142
172
|
- app/views/layouts/fine_print/application.html.erb
|
143
173
|
- config/initializers/fine_print.rb
|
144
174
|
- config/routes.rb
|
@@ -146,7 +176,6 @@ files:
|
|
146
176
|
- lib/fine_print.rb
|
147
177
|
- lib/fine_print/controller_includes.rb
|
148
178
|
- lib/fine_print/engine.rb
|
149
|
-
- lib/fine_print/security_transgression.rb
|
150
179
|
- lib/fine_print/version.rb
|
151
180
|
- lib/tasks/fine_print_tasks.rake
|
152
181
|
- spec/controllers/contracts_controller_spec.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<h1 class='fine_print heading'>FinePrint</h1>
|
2
|
-
|
3
|
-
<div class='fine_print root'>
|
4
|
-
<ul class='fine_print'>
|
5
|
-
<li>
|
6
|
-
<%= link_to 'Manage contracts',
|
7
|
-
contracts_path,
|
8
|
-
:class => 'fine_print link' %>
|
9
|
-
</li>
|
10
|
-
<li>
|
11
|
-
<%= link_to 'View signatures',
|
12
|
-
signatures_path,
|
13
|
-
:class => 'fine_print link' %>
|
14
|
-
</li>
|
15
|
-
</ul>
|
16
|
-
</div>
|