fine_print 6.0.1 → 6.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/lib/fine_print/action_controller/base.rb +3 -1
  4. data/lib/fine_print/version.rb +1 -1
  5. metadata +9 -169
  6. data/spec/controllers/contracts_controller_spec.rb +0 -222
  7. data/spec/controllers/home_controller_spec.rb +0 -27
  8. data/spec/controllers/signatures_controller_spec.rb +0 -68
  9. data/spec/dummy/Rakefile +0 -6
  10. data/spec/dummy/app/assets/config/manifest.js +0 -4
  11. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  12. data/spec/dummy/app/assets/javascripts/cable.js +0 -13
  13. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  14. data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
  15. data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
  16. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  17. data/spec/dummy/app/controllers/dummy_models_controller.rb +0 -2
  18. data/spec/dummy/app/helpers/application_helper.rb +0 -15
  19. data/spec/dummy/app/jobs/application_job.rb +0 -2
  20. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  21. data/spec/dummy/app/models/application_record.rb +0 -3
  22. data/spec/dummy/app/models/dummy_user.rb +0 -2
  23. data/spec/dummy/app/views/layouts/application.html.erb +0 -15
  24. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  25. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  26. data/spec/dummy/bin/bundle +0 -3
  27. data/spec/dummy/bin/rails +0 -4
  28. data/spec/dummy/bin/rake +0 -4
  29. data/spec/dummy/bin/setup +0 -36
  30. data/spec/dummy/bin/update +0 -31
  31. data/spec/dummy/bin/yarn +0 -11
  32. data/spec/dummy/config/application.rb +0 -25
  33. data/spec/dummy/config/boot.rb +0 -5
  34. data/spec/dummy/config/cable.yml +0 -10
  35. data/spec/dummy/config/database.yml +0 -25
  36. data/spec/dummy/config/environment.rb +0 -5
  37. data/spec/dummy/config/environments/development.rb +0 -61
  38. data/spec/dummy/config/environments/production.rb +0 -94
  39. data/spec/dummy/config/environments/test.rb +0 -46
  40. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
  41. data/spec/dummy/config/initializers/assets.rb +0 -14
  42. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  43. data/spec/dummy/config/initializers/content_security_policy.rb +0 -25
  44. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
  45. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  46. data/spec/dummy/config/initializers/fine_print.rb +0 -6
  47. data/spec/dummy/config/initializers/inflections.rb +0 -16
  48. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  50. data/spec/dummy/config/locales/en.yml +0 -33
  51. data/spec/dummy/config/puma.rb +0 -34
  52. data/spec/dummy/config/routes.rb +0 -3
  53. data/spec/dummy/config/spring.rb +0 -6
  54. data/spec/dummy/config/storage.yml +0 -34
  55. data/spec/dummy/config.ru +0 -5
  56. data/spec/dummy/db/development.sqlite3 +0 -0
  57. data/spec/dummy/db/migrate/1000_create_dummy_users.rb +0 -9
  58. data/spec/dummy/db/schema.rb +0 -42
  59. data/spec/dummy/db/test.sqlite3 +0 -0
  60. data/spec/dummy/log/development.log +0 -95
  61. data/spec/dummy/log/test.log +0 -5352
  62. data/spec/dummy/package.json +0 -5
  63. data/spec/dummy/public/404.html +0 -67
  64. data/spec/dummy/public/422.html +0 -67
  65. data/spec/dummy/public/500.html +0 -66
  66. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  67. data/spec/dummy/public/apple-touch-icon.png +0 -0
  68. data/spec/dummy/public/favicon.ico +0 -0
  69. data/spec/dummy/tmp/development_secret.txt +0 -1
  70. data/spec/factories/fine_print/contract.rb +0 -26
  71. data/spec/factories/fine_print/signature.rb +0 -17
  72. data/spec/factories/user.rb +0 -4
  73. data/spec/lib/fine_print/action_controller/base_spec.rb +0 -30
  74. data/spec/lib/fine_print_spec.rb +0 -63
  75. data/spec/models/contract_spec.rb +0 -89
  76. data/spec/models/signature_spec.rb +0 -18
  77. data/spec/spec_helper.rb +0 -23
  78. data/spec/support/controller.rb +0 -11
@@ -1,5 +0,0 @@
1
- {
2
- "name": "dummy",
3
- "private": true,
4
- "dependencies": {}
5
- }
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
File without changes
File without changes
@@ -1 +0,0 @@
1
- 0e361972093e2a13910b61f6f25710cf554e8aae62fb8a55fdda2683f7f3583e29e5e351ccedbd819e8ec6b1dee9fb9811eac9421e7aeae8c449ef773d8862f6
@@ -1,26 +0,0 @@
1
- FactoryBot.define do
2
- factory :fine_print_contract, class: FinePrint::Contract do
3
- name { Faker::Lorem.words.join('_') }
4
- title { Faker::Lorem.words.join(' ').capitalize }
5
- content { Faker::Lorem.paragraphs.join("\n") }
6
-
7
- trait :published do
8
- transient do
9
- user_factory { :user }
10
- signatures_count { 0 }
11
- end
12
-
13
- after(:build) do |contract, evaluator|
14
- contract.version = (contract.same_name.published
15
- .first.try(:version) || 0) + 1
16
-
17
- evaluator.signatures_count.times do
18
- contract.signatures << FactoryBot.build(
19
- :fine_print_signature,
20
- user_factory: evaluator.user_factory
21
- )
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,17 +0,0 @@
1
- FactoryBot.define do
2
- factory :fine_print_signature, class: FinePrint::Signature do
3
- association :contract, factory: [:fine_print_contract, :published]
4
-
5
- trait :implicit do
6
- is_implicit { FinePrint::SIGNATURE_IS_IMPLICIT }
7
- end
8
-
9
- transient do
10
- user_factory { :user }
11
- end
12
-
13
- after(:build) do |signature, evaluator|
14
- signature.user ||= FactoryBot.build(evaluator.user_factory)
15
- end
16
- end
17
- end
@@ -1,4 +0,0 @@
1
- FactoryBot.define do
2
- factory :user, class: DummyUser do
3
- end
4
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module FinePrint
4
- module ActionController
5
- RSpec.describe Base, type: :lib do
6
- let!(:controller) { ::ActionController::Base.new }
7
- let!(:dummy_controller) { DummyModelsController.new }
8
-
9
- it 'must add fine_print_sign to ActionController instances' do
10
- expect(controller).to respond_to(:fine_print_require)
11
- expect(dummy_controller).to respond_to(:fine_print_require)
12
- end
13
-
14
- it 'must add fine_print_return to ActionController instances' do
15
- expect(controller.respond_to?(:fine_print_return, true)).to eq true
16
- expect(dummy_controller.respond_to?(:fine_print_return, true)).to eq true
17
- end
18
-
19
- it 'must add fine_print_require to ActionController and subclasses' do
20
- expect(controller.class).to respond_to(:fine_print_require)
21
- expect(dummy_controller.class).to respond_to(:fine_print_require)
22
- end
23
-
24
- it 'must add fine_print_skip to ActionController and subclasses' do
25
- expect(controller.class).to respond_to(:fine_print_skip)
26
- expect(dummy_controller.class).to respond_to(:fine_print_skip)
27
- end
28
- end
29
- end
30
- end
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe FinePrint, type: :lib do
4
- before :each do
5
- @alpha_1 = FactoryBot.create(:fine_print_contract, :published, name: 'alpha')
6
- @beta_1 = FactoryBot.create(:fine_print_contract, :published, name: 'beta')
7
-
8
- @user = DummyUser.create
9
- @alpha_1_sig = FactoryBot.create(:fine_print_signature, contract: @alpha_1, user: @user)
10
- @beta_1_sig = FactoryBot.create(:fine_print_signature, contract: @beta_1, user: @user)
11
-
12
- @alpha_2 = @alpha_1.new_version
13
- @alpha_2.update_attribute(:content, 'foo')
14
- @alpha_2.publish
15
- end
16
-
17
- it 'gets contracts' do
18
- expect(FinePrint.get_contract(@beta_1)).to eq @beta_1
19
- expect(FinePrint.get_contract(@beta_1.id)).to eq @beta_1
20
- expect(FinePrint.get_contract('beta')).to eq @beta_1
21
- expect(FinePrint.get_contract(@alpha_1)).to eq @alpha_1
22
- expect(FinePrint.get_contract(@alpha_1.id)).to eq @alpha_1
23
- expect(FinePrint.get_contract('alpha')).to eq @alpha_2
24
- end
25
-
26
- it 'gets signed contracts' do
27
- expect(FinePrint.signed_contracts_for(@user)).to eq [@beta_1]
28
- end
29
-
30
- it 'gets unsigned contracts' do
31
- names = [@alpha_2, @beta_1].map(&:name)
32
- expect(FinePrint.unsigned_contracts_for(@user, name: names)).to eq [@alpha_2]
33
- end
34
-
35
- it 'allows users to sign contracts' do
36
- expect(FinePrint.signed_contract?(@user, @alpha_1)).to eq true
37
- expect(FinePrint.signed_contract?(@user, @alpha_2)).to eq false
38
- expect(FinePrint.signed_contract?(@user, @beta_1)).to eq true
39
- expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_1)).to eq true
40
- expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_2)).to eq true
41
- expect(FinePrint.signed_any_version_of_contract?(@user, @beta_1)).to eq true
42
-
43
- expect(FinePrint.sign_contract(@user, @alpha_2)).to be_a FinePrint::Signature
44
-
45
- expect(FinePrint.signed_contract?(@user, @alpha_1)).to eq true
46
- expect(FinePrint.signed_contract?(@user, @alpha_2)).to eq true
47
- expect(FinePrint.signed_contract?(@user, @beta_1)).to eq true
48
- expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_1)).to eq true
49
- expect(FinePrint.signed_any_version_of_contract?(@user, @alpha_2)).to eq true
50
- expect(FinePrint.signed_any_version_of_contract?(@user, @beta_1)).to eq true
51
- end
52
-
53
- it 'can record implicit signatures' do
54
- signature = FinePrint.sign_contract(@user, @alpha_2, FinePrint::SIGNATURE_IS_IMPLICIT)
55
-
56
- expect(signature.is_implicit?).to eq true
57
- expect(signature.is_explicit?).to eq false
58
- end
59
-
60
- it 'records signatures explicitly by default' do
61
- expect(FinePrint.sign_contract(@user, @alpha_2).is_explicit?).to eq true
62
- end
63
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module FinePrint
4
- RSpec.describe Contract, type: :model do
5
- it 'can be published and unpublished' do
6
- contract = FactoryBot.create(:fine_print_contract)
7
- expect(contract.is_published?).to eq false
8
- expect(contract.version).to be_nil
9
- expect(contract.is_latest?).to eq false
10
- expect(contract.signatures).to be_empty
11
-
12
- contract.unpublish
13
- expect(contract.errors).not_to be_empty
14
- contract.errors.clear
15
- expect(contract.errors).to be_empty
16
- contract.publish
17
- expect(contract.errors).to be_empty
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
22
-
23
- contract.publish
24
- expect(contract.errors).not_to be_empty
25
- contract.errors.clear
26
- expect(contract.errors).to be_empty
27
- contract.unpublish
28
- expect(contract.errors).to be_empty
29
- expect(contract.is_published?).to eq false
30
- end
31
-
32
- it "can't be modified after a user signs it" do
33
- contract = FactoryBot.create(:fine_print_contract)
34
-
35
- contract.publish
36
- expect(contract.is_published?).to eq true
37
- expect(contract.signatures).to be_empty
38
-
39
- ua = FactoryBot.create(:fine_print_signature, contract: contract)
40
- contract.reload
41
- expect(contract.signatures).not_to be_empty
42
-
43
- contract.save
44
- expect(contract.errors).not_to be_empty
45
- contract.errors.clear
46
- expect(contract.errors).to be_empty
47
- contract.unpublish
48
- expect(contract.errors).not_to be_empty
49
- expect(contract.reload.is_published?).to eq true
50
- end
51
-
52
- it 'results in a new version if a copy is published' do
53
- contract = FactoryBot.create(:fine_print_contract, :published)
54
- expect(contract.version).to eq 1
55
- new_version = contract.new_version
56
- expect(new_version.save).to eq true
57
- new_version.publish
58
- expect(new_version.version).to eq 2
59
- end
60
-
61
- it 'results in a first version if a name is changed after publishing' do
62
- contract = FactoryBot.create(:fine_print_contract, :published)
63
- expect(contract.version).to eq 1
64
- new_version = contract.new_version
65
- new_version.name = 'Joe'
66
- expect(new_version.save).to eq true
67
- new_version.publish
68
- expect(new_version.version).to eq 1
69
- end
70
-
71
- it 'calls the contract_published_proc after publish' do
72
- original_proc = FinePrint.config.contract_published_proc
73
-
74
- begin
75
- FinePrint.config.contract_published_proc = lambda do |contract|
76
- contract.name = 'Deep Thought'
77
- end
78
- contract = FactoryBot.create(:fine_print_contract, name: '42')
79
- contract.publish
80
- expect(contract.name).to eq 'Deep Thought'
81
- rescue
82
- fail
83
- ensure
84
- FinePrint.config.contract_published_proc = original_proc
85
- end
86
- end
87
-
88
- end
89
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module FinePrint
4
- RSpec.describe Signature, type: :model do
5
- it "can't be associated with unpublished contracts" do
6
- contract = FactoryBot.create(:fine_print_contract)
7
- expect(contract.is_published?).to eq false
8
- expect(contract.signatures).to be_empty
9
-
10
- sig = FactoryBot.build(:fine_print_signature)
11
- sig.contract = contract
12
- expect(sig.save).to eq false
13
-
14
- contract.reload
15
- expect(contract.signatures).to be_empty
16
- end
17
- end
18
- end
data/spec/spec_helper.rb DELETED
@@ -1,23 +0,0 @@
1
- ENV['RAILS_ENV'] ||= 'test'
2
-
3
- require 'coveralls'
4
- Coveralls.wear!('rails')
5
-
6
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
7
- require 'rspec/rails'
8
- require 'factory_bot_rails'
9
- require 'faker'
10
- require 'rails-controller-testing'
11
- Rails::Controller::Testing.install
12
-
13
- Rails.backtrace_cleaner.remove_silencers!
14
-
15
- # Load support files
16
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
17
-
18
- RSpec.configure do |config|
19
- config.mock_with :rspec
20
- config.use_transactional_fixtures = false
21
- config.infer_base_class_for_anonymous_controllers = false
22
- config.order = 'random'
23
- end
@@ -1,11 +0,0 @@
1
- FinePrint::ApplicationController.class_eval do
2
- include ApplicationHelper
3
- end
4
-
5
- def setup_controller_spec
6
- class_eval { include ApplicationHelper }
7
- sign_out
8
- @user = FactoryBot.create(:user)
9
- @admin = FactoryBot.create(:user)
10
- @admin.is_admin = true
11
- end