fine_print 1.3.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +56 -44
  3. data/app/controllers/fine_print/application_controller.rb +0 -3
  4. data/app/models/fine_print/contract.rb +9 -8
  5. data/app/models/fine_print/signature.rb +1 -1
  6. data/config/initializers/fine_print.rb +20 -16
  7. data/db/migrate/0_install_fine_print.rb +4 -3
  8. data/lib/fine_print/controller_includes.rb +114 -0
  9. data/lib/fine_print/version.rb +1 -1
  10. data/lib/fine_print.rb +20 -24
  11. data/spec/controllers/contracts_controller_spec.rb +38 -36
  12. data/spec/controllers/home_controller_spec.rb +4 -4
  13. data/spec/controllers/signatures_controller_spec.rb +8 -8
  14. data/spec/dummy/Rakefile +0 -1
  15. data/spec/dummy/app/assets/javascripts/application.js +3 -5
  16. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  17. data/spec/dummy/bin/bundle +3 -0
  18. data/spec/dummy/bin/rails +4 -0
  19. data/spec/dummy/bin/rake +4 -0
  20. data/spec/dummy/config/application.rb +3 -37
  21. data/spec/dummy/config/boot.rb +4 -9
  22. data/spec/dummy/config/environment.rb +2 -2
  23. data/spec/dummy/config/environments/development.rb +11 -19
  24. data/spec/dummy/config/environments/production.rb +40 -27
  25. data/spec/dummy/config/environments/test.rb +13 -14
  26. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  27. data/spec/dummy/config/initializers/fine_print.rb +1 -34
  28. data/spec/dummy/config/initializers/inflections.rb +6 -5
  29. data/spec/dummy/config/initializers/secret_token.rb +7 -2
  30. data/spec/dummy/config/initializers/session_store.rb +1 -6
  31. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  32. data/spec/dummy/config/locales/en.yml +20 -2
  33. data/spec/dummy/config/routes.rb +2 -1
  34. data/spec/dummy/config.ru +1 -1
  35. data/spec/dummy/db/development.sqlite3 +0 -0
  36. data/spec/dummy/db/schema.rb +21 -21
  37. data/spec/dummy/db/test.sqlite3 +0 -0
  38. data/spec/dummy/log/development.log +15 -1849
  39. data/spec/dummy/log/test.log +10536 -53785
  40. data/spec/dummy/public/404.html +43 -11
  41. data/spec/dummy/public/422.html +43 -11
  42. data/spec/dummy/public/500.html +43 -11
  43. data/spec/factories/contract.rb +2 -2
  44. data/spec/lib/fine_print/{controller_additions_spec.rb → controller_includes_spec.rb} +16 -6
  45. metadata +104 -166
  46. data/app/assets/javascripts/application.js~ +0 -16
  47. data/app/controllers/fine_print/application_controller.rb~ +0 -15
  48. data/app/controllers/fine_print/contracts_controller.rb~ +0 -79
  49. data/app/controllers/fine_print/home_controller.rb~ +0 -6
  50. data/app/controllers/fine_print/signatures_controller.rb~ +0 -14
  51. data/app/helpers/fine_print/application_helper.rb~ +0 -7
  52. data/app/helpers/fine_print/contracts_helper.rb~ +0 -7
  53. data/app/models/fine_print/contract.rb~ +0 -100
  54. data/app/models/fine_print/signature.rb~ +0 -25
  55. data/app/views/fine_print/contracts/_form.html.erb~ +0 -35
  56. data/app/views/fine_print/contracts/index.html.erb~ +0 -43
  57. data/app/views/fine_print/contracts/show.html.erb~ +0 -35
  58. data/app/views/fine_print/home/index.html.erb~ +0 -15
  59. data/app/views/fine_print/signatures/index.html.erb~ +0 -32
  60. data/app/views/layouts/fine_print/application.html.erb~ +0 -20
  61. data/config/initializers/fine_print.rb~ +0 -36
  62. data/config/routes.rb~ +0 -12
  63. data/db/migrate/0_install_fine_print.rb~ +0 -26
  64. data/lib/fine_print/controller_additions.rb +0 -80
  65. data/lib/fine_print/controller_additions.rb~ +0 -86
  66. data/lib/fine_print/utilities.rb~ +0 -26
  67. data/lib/fine_print/version.rb~ +0 -3
  68. data/lib/fine_print.rb~ +0 -120
  69. data/spec/controllers/contracts_controller_spec.rb~ +0 -224
  70. data/spec/controllers/home_controller_spec.rb~ +0 -25
  71. data/spec/controllers/signatures_controller_spec.rb~ +0 -46
  72. data/spec/dummy/app/controllers/dummy_models_controller.rb~ +0 -29
  73. data/spec/dummy/app/models/dummy_user.rb~ +0 -4
  74. data/spec/dummy/app/models/user.rb~ +0 -78
  75. data/spec/dummy/config/application.rb~ +0 -60
  76. data/spec/dummy/config/initializers/fine_print.rb~ +0 -36
  77. data/spec/dummy/config/initializers/session_store.rb~ +0 -8
  78. data/spec/dummy/config/initializers/wrap_parameters.rb~ +0 -14
  79. data/spec/dummy/config/routes.rb~ +0 -4
  80. data/spec/dummy/db/migrate/1_create_dummy_users.rb~ +0 -8
  81. data/spec/dummy/script/rails +0 -6
  82. data/spec/factories/contract.rb~ +0 -26
  83. data/spec/factories/dummy_user.rb~ +0 -6
  84. data/spec/factories/signature.rb~ +0 -8
  85. data/spec/factories/user.rb~ +0 -6
  86. data/spec/fine_print_spec.rb~ +0 -18
  87. data/spec/lib/fine_print/controller_additions_spec.rb~ +0 -20
  88. data/spec/lib/fine_print_spec.rb~ +0 -47
  89. data/spec/models/contract_spec.rb~ +0 -80
  90. data/spec/models/signature_spec.rb~ +0 -28
  91. data/spec/spec_helper.rb~ +0 -32
  92. data/spec/test_helper.rb~ +0 -15
@@ -1,26 +0,0 @@
1
- FactoryGirl.define do
2
- factory :contract, :class => FinePrint::Contract do
3
-
4
- name { "Contract_#{SecureRandom.hex(4)}" }
5
- title { Faker::Lorem.sentence(3) }
6
- content { Faker::Lorem.paragraphs(2) }
7
-
8
- factory :published_contract do
9
- after(:create) {|instance| instance.publish }
10
- end
11
-
12
- factory :signed_contract do
13
- after(:build) {|instance| instance.save; instance.publish }
14
-
15
- ignore do
16
- count 2
17
- end
18
-
19
- after(:build) do |contract, evaluator|
20
- evaluator.count.times do
21
- contract.signatures << FactoryGirl.build(:signature)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,6 +0,0 @@
1
- require 'rspec-rails'
2
-
3
- FactoryGirl.define do
4
- factory :dummy_user, :class => DummyUser do
5
- end
6
- end
@@ -1,8 +0,0 @@
1
- require 'rspec-rails'
2
-
3
- FactoryGirl.define do
4
- factory :signature, :class => FinePrint::Signature do
5
- association :contract, :factory => :published_contract
6
- association :user, :factory => :dummy_user
7
- end
8
- end
@@ -1,6 +0,0 @@
1
- require 'rspec-rails'
2
-
3
- FactoryGirl.define do
4
- factory :user, :class => DummyUser do
5
- end
6
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FinePrint do
4
- it 'gets unsigned contracts' do
5
- alpha_1 = FactoryGirl.create(:published_contract, :name => 'alpha')
6
- beta_1 = FactoryGirl.create(:published_contract, :name => 'beta')
7
-
8
- user = mock_model 'DummyUser', :id => -1
9
- alpha_1_sig = FactoryGirl.create(:signature, :contract => alpha_1, :user => user)
10
- beta_1_sig = FactoryGirl.create(:signature, :contract => beta_1, :user => user)
11
-
12
- alpha_2 = alpha_1.draft_copy
13
- alpha_2.update_attributes(:content => 'foo')
14
- alpha_2.publish
15
-
16
- expect(FinePrint.get_unsigned_contract_names(:names => ['beta', 'alpha'], :user => user)).to eq ['alpha']
17
- end
18
- end
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- module FinePrint
4
- describe ControllerAdditions do
5
- it 'must add fine_print_get_signatures to ActionController and subclasses' do
6
- expect(ActionController::Base.respond_to? :fine_print_get_signatures).to eq true
7
- expect(DummyModelsController.respond_to? :fine_print_get_signatures).to eq true
8
- end
9
-
10
- it 'must add fine_print_skip_signatures to ActionController and subclasses' do
11
- expect(ActionController::Base.respond_to? :fine_print_skip_signatures).to eq true
12
- expect(DummyModelsController.respond_to? :fine_print_skip_signatures).to eq true
13
- end
14
-
15
- it 'must add fine_print_return to ActionController instances' do
16
- expect(ActionController::Base.new.respond_to?(:fine_print_return, true)).to eq true
17
- expect(DummyModelsController.new.respond_to?(:fine_print_return, true)).to eq true
18
- end
19
- end
20
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FinePrint do
4
- before :each do
5
- @alpha_1 = FactoryGirl.create(:published_contract, :name => 'alpha')
6
- @beta_1 = FactoryGirl.create(:published_contract, :name => 'beta')
7
-
8
- @user = mock_model 'DummyUser', :id => -1
9
- @alpha_1_sig = FactoryGirl.create(:signature, :contract => @alpha_1, :user => @user)
10
- @beta_1_sig = FactoryGirl.create(:signature, :contract => @beta_1, :user => @user)
11
-
12
- @alpha_2 = @alpha_1.draft_copy
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 unsigned contracts' do
27
- expect(FinePrint.get_unsigned_contract_names(['beta', 'alpha'], @user)).to eq ['alpha']
28
- end
29
-
30
- it 'allows users to sign contracts' do
31
- expect(FinePrint.signed_contract?(@user, @alpha_1)).to eq true
32
- expect(FinePrint.signed_contract?(@user, @alpha_2)).to eq false
33
- expect(FinePrint.signed_contract?(@user, @beta_1)).to eq true
34
- expect(FinePrint.signed_any_contract_version?(@user, @alpha_1)).to eq true
35
- expect(FinePrint.signed_any_contract_version?(@user, @alpha_2)).to eq true
36
- expect(FinePrint.signed_any_contract_version?(@user, @beta_1)).to eq true
37
-
38
- expect(FinePrint.sign_contract(@user, @alpha_2)).to be_a FinePrint::Signature
39
-
40
- expect(FinePrint.signed_contract?(@user, @alpha_1)).to eq true
41
- expect(FinePrint.signed_contract?(@user, @alpha_2)).to eq true
42
- expect(FinePrint.signed_contract?(@user, @beta_1)).to eq true
43
- expect(FinePrint.signed_any_contract_version?(@user, @alpha_1)).to eq true
44
- expect(FinePrint.signed_any_contract_version?(@user, @alpha_2)).to eq true
45
- expect(FinePrint.signed_any_contract_version?(@user, @beta_1)).to eq true
46
- end
47
- end
@@ -1,80 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module FinePrint
4
- describe Contract do
5
- it 'can be published and unpublished' do
6
- contract = FactoryGirl.create(:contract)
7
- expect(contract.is_published?).to be_false
8
- expect(contract.version).to be_nil
9
- expect(contract.is_latest?).to be_false
10
- expect(contract.can_be_updated?).to be_true
11
- expect(contract.can_be_published?).to be_true
12
- expect(contract.can_be_unpublished?).to be_false
13
-
14
- contract.unpublish
15
- expect(contract.errors).not_to be_empty
16
- contract.errors.clear
17
- expect(contract.errors).to be_empty
18
- contract.publish
19
- expect(contract.errors).to be_empty
20
- expect(contract.is_published?).to be_true
21
- expect(contract.version).to be 1
22
- expect(contract.is_latest?).to be_true
23
- expect(contract.can_be_updated?).to be_true
24
- expect(contract.can_be_published?).to be_false
25
- expect(contract.can_be_unpublished?).to be_true
26
-
27
- contract.publish
28
- expect(contract.errors).not_to be_empty
29
- contract.errors.clear
30
- expect(contract.errors).to be_empty
31
- contract.unpublish
32
- expect(contract.errors).to be_empty
33
- expect(contract.is_published?).to be_false
34
- end
35
-
36
- it "can't be modified after a user signs" do
37
- contract = FactoryGirl.create(:contract)
38
-
39
- contract.publish
40
- expect(contract.is_published?).to be_true
41
- contract.reload
42
- expect(contract.can_be_updated?).to be_true
43
- expect(contract.can_be_published?).to be_false
44
- expect(contract.can_be_unpublished?).to be_true
45
-
46
- ua = FactoryGirl.create(:signature, :contract => contract)
47
- contract.reload
48
- expect(contract.can_be_updated?).to be_false
49
- expect(contract.can_be_published?).to be_false
50
- expect(contract.can_be_unpublished?).to be_false
51
-
52
- contract.save
53
- expect(contract.errors).not_to be_empty
54
- contract.errors.clear
55
- expect(contract.errors).to be_empty
56
- contract.unpublish
57
- expect(contract.errors).not_to be_empty
58
- expect(contract.is_published?).to be_true
59
- end
60
-
61
- it 'results in a new version if a copy is published' do
62
- contract = FactoryGirl.create(:published_contract)
63
- expect(contract.version).to eq 1
64
- new_version = contract.draft_copy
65
- expect(new_version.save).to be_true
66
- new_version.publish
67
- expect(new_version.version).to eq 2
68
- end
69
-
70
- it 'results in a first version if a name is changed after publishing' do
71
- contract = FactoryGirl.create(:published_contract)
72
- expect(contract.version).to eq 1
73
- new_version = contract.draft_copy
74
- new_version.name = 'Joe'
75
- expect(new_version.save).to be_true
76
- new_version.publish
77
- expect(new_version.version).to eq 1
78
- end
79
- end
80
- end
@@ -1,28 +0,0 @@
1
- require 'test_helper'
2
-
3
- module FinePrint
4
- describe Signature do
5
- it 'can''t be associated with unpublished contracts' do
6
- contract = FactoryGirl.create(:contract)
7
- expect(contract.is_published?).to be_false
8
- expect(contract.can_be_updated?).to be_true
9
-
10
- sig = FactoryGirl.build(:signature)
11
- sig.contract = contract
12
- expect(sig.save).to be_false
13
-
14
- contract.reload
15
- expect(contract.can_be_updated?).to be_true
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
26
- end
27
- end
28
- end
data/spec/spec_helper.rb~ DELETED
@@ -1,32 +0,0 @@
1
- ENV['RAILS_ENV'] ||= 'test'
2
-
3
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
- require 'rspec/rails'
5
- require 'rspec/autorun'
6
- require 'factory_girl_rails'
7
- require 'faker'
8
-
9
- Rails.backtrace_cleaner.remove_silencers!
10
-
11
- # Load support files
12
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
13
-
14
- RSpec.configure do |config|
15
- config.mock_with :rspec
16
- config.use_transactional_fixtures = true
17
- config.infer_base_class_for_anonymous_controllers = false
18
- config.order = 'random'
19
- end
20
-
21
- FinePrint::ApplicationController.class_eval do
22
- include ApplicationHelper
23
- end
24
-
25
- def setup_controller_spec
26
- class_eval { include ApplicationHelper }
27
- routes { FinePrint::Engine.routes }
28
- sign_out
29
- @user = FactoryGirl.create(:dummy_user)
30
- @admin = FactoryGirl.create(:dummy_user)
31
- @admin.is_admin = true
32
- end
data/spec/test_helper.rb~ DELETED
@@ -1,15 +0,0 @@
1
- ENV['RAILS_ENV'] = 'test'
2
- require File.expand_path('../dummy/config/environment', __FILE__)
3
- require 'rails/test_help'
4
- require 'minitest/rails'
5
- require 'factory_girl_rails'
6
- require 'faker'
7
-
8
- # To add Capybara feature tests add `gem "minitest-rails-capybara"`
9
- # to the test group in the Gemfile and uncomment the following:
10
- # require "minitest/rails/capybara"
11
-
12
- # Uncomment for awesome colorful output
13
- # require "minitest/pride"
14
-
15
- Rails.backtrace_cleaner.remove_silencers!