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.
- checksums.yaml +4 -4
- data/README.md +56 -44
- data/app/controllers/fine_print/application_controller.rb +0 -3
- data/app/models/fine_print/contract.rb +9 -8
- data/app/models/fine_print/signature.rb +1 -1
- data/config/initializers/fine_print.rb +20 -16
- data/db/migrate/0_install_fine_print.rb +4 -3
- data/lib/fine_print/controller_includes.rb +114 -0
- data/lib/fine_print/version.rb +1 -1
- data/lib/fine_print.rb +20 -24
- data/spec/controllers/contracts_controller_spec.rb +38 -36
- data/spec/controllers/home_controller_spec.rb +4 -4
- data/spec/controllers/signatures_controller_spec.rb +8 -8
- data/spec/dummy/Rakefile +0 -1
- data/spec/dummy/app/assets/javascripts/application.js +3 -5
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +3 -37
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/environment.rb +2 -2
- data/spec/dummy/config/environments/development.rb +11 -19
- data/spec/dummy/config/environments/production.rb +40 -27
- data/spec/dummy/config/environments/test.rb +13 -14
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/fine_print.rb +1 -34
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -2
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/routes.rb +2 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +21 -21
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +15 -1849
- data/spec/dummy/log/test.log +10536 -53785
- data/spec/dummy/public/404.html +43 -11
- data/spec/dummy/public/422.html +43 -11
- data/spec/dummy/public/500.html +43 -11
- data/spec/factories/contract.rb +2 -2
- data/spec/lib/fine_print/{controller_additions_spec.rb → controller_includes_spec.rb} +16 -6
- metadata +104 -166
- data/app/assets/javascripts/application.js~ +0 -16
- data/app/controllers/fine_print/application_controller.rb~ +0 -15
- data/app/controllers/fine_print/contracts_controller.rb~ +0 -79
- data/app/controllers/fine_print/home_controller.rb~ +0 -6
- data/app/controllers/fine_print/signatures_controller.rb~ +0 -14
- data/app/helpers/fine_print/application_helper.rb~ +0 -7
- data/app/helpers/fine_print/contracts_helper.rb~ +0 -7
- data/app/models/fine_print/contract.rb~ +0 -100
- data/app/models/fine_print/signature.rb~ +0 -25
- data/app/views/fine_print/contracts/_form.html.erb~ +0 -35
- data/app/views/fine_print/contracts/index.html.erb~ +0 -43
- data/app/views/fine_print/contracts/show.html.erb~ +0 -35
- data/app/views/fine_print/home/index.html.erb~ +0 -15
- data/app/views/fine_print/signatures/index.html.erb~ +0 -32
- data/app/views/layouts/fine_print/application.html.erb~ +0 -20
- data/config/initializers/fine_print.rb~ +0 -36
- data/config/routes.rb~ +0 -12
- data/db/migrate/0_install_fine_print.rb~ +0 -26
- data/lib/fine_print/controller_additions.rb +0 -80
- data/lib/fine_print/controller_additions.rb~ +0 -86
- data/lib/fine_print/utilities.rb~ +0 -26
- data/lib/fine_print/version.rb~ +0 -3
- data/lib/fine_print.rb~ +0 -120
- data/spec/controllers/contracts_controller_spec.rb~ +0 -224
- data/spec/controllers/home_controller_spec.rb~ +0 -25
- data/spec/controllers/signatures_controller_spec.rb~ +0 -46
- data/spec/dummy/app/controllers/dummy_models_controller.rb~ +0 -29
- data/spec/dummy/app/models/dummy_user.rb~ +0 -4
- data/spec/dummy/app/models/user.rb~ +0 -78
- data/spec/dummy/config/application.rb~ +0 -60
- data/spec/dummy/config/initializers/fine_print.rb~ +0 -36
- data/spec/dummy/config/initializers/session_store.rb~ +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb~ +0 -14
- data/spec/dummy/config/routes.rb~ +0 -4
- data/spec/dummy/db/migrate/1_create_dummy_users.rb~ +0 -8
- data/spec/dummy/script/rails +0 -6
- data/spec/factories/contract.rb~ +0 -26
- data/spec/factories/dummy_user.rb~ +0 -6
- data/spec/factories/signature.rb~ +0 -8
- data/spec/factories/user.rb~ +0 -6
- data/spec/fine_print_spec.rb~ +0 -18
- data/spec/lib/fine_print/controller_additions_spec.rb~ +0 -20
- data/spec/lib/fine_print_spec.rb~ +0 -47
- data/spec/models/contract_spec.rb~ +0 -80
- data/spec/models/signature_spec.rb~ +0 -28
- data/spec/spec_helper.rb~ +0 -32
- data/spec/test_helper.rb~ +0 -15
data/spec/factories/contract.rb~
DELETED
@@ -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
|
data/spec/factories/user.rb~
DELETED
data/spec/fine_print_spec.rb~
DELETED
@@ -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!
|