fine_print 0.1.1 → 1.0.0
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.
- checksums.yaml +7 -0
- data/README.md +74 -45
- data/Rakefile +9 -9
- data/app/assets/javascripts/application.js~ +16 -0
- data/app/assets/javascripts/fine_print/application.js +8 -2
- data/app/controllers/fine_print/application_controller.rb +9 -7
- data/app/controllers/fine_print/application_controller.rb~ +9 -7
- data/app/controllers/fine_print/contracts_controller.rb +79 -0
- data/app/controllers/fine_print/contracts_controller.rb~ +79 -0
- data/app/controllers/fine_print/home_controller.rb +1 -11
- data/app/controllers/fine_print/home_controller.rb~ +2 -11
- data/app/controllers/fine_print/signatures_controller.rb +14 -0
- data/app/controllers/fine_print/signatures_controller.rb~ +14 -0
- data/app/helpers/fine_print/application_helper.rb +7 -0
- data/app/helpers/fine_print/application_helper.rb~ +7 -0
- data/app/helpers/fine_print/contracts_helper.rb~ +7 -0
- data/app/models/fine_print/contract.rb +96 -0
- data/app/models/fine_print/contract.rb~ +100 -0
- data/app/models/fine_print/signature.rb +25 -0
- data/app/models/fine_print/signature.rb~ +25 -0
- data/app/views/fine_print/contracts/_form.html.erb +35 -0
- data/app/views/fine_print/contracts/_form.html.erb~ +35 -0
- data/app/views/fine_print/contracts/edit.html.erb +10 -0
- data/app/views/fine_print/contracts/index.html.erb +43 -0
- data/app/views/fine_print/contracts/index.html.erb~ +43 -0
- data/app/views/fine_print/contracts/new.html.erb +9 -0
- data/app/views/fine_print/contracts/new_version.html.erb +9 -0
- data/app/views/fine_print/contracts/show.html.erb +33 -0
- data/app/views/fine_print/contracts/show.html.erb~ +35 -0
- data/app/views/fine_print/home/index.html.erb +15 -6
- data/app/views/fine_print/home/index.html.erb~ +12 -4
- data/app/views/fine_print/signatures/index.html.erb +36 -0
- data/app/views/fine_print/signatures/index.html.erb~ +32 -0
- data/app/views/layouts/fine_print/application.html.erb +6 -0
- data/app/views/layouts/fine_print/application.html.erb~ +20 -0
- data/config/initializers/fine_print.rb +27 -44
- data/config/initializers/fine_print.rb~ +23 -40
- data/config/routes.rb +9 -3
- data/config/routes.rb~ +9 -4
- data/db/migrate/0_install_fine_print.rb +26 -0
- data/db/migrate/0_install_fine_print.rb~ +26 -0
- data/lib/fine_print/controller_additions.rb +69 -0
- data/lib/fine_print/controller_additions.rb~ +69 -0
- data/lib/fine_print/engine.rb +8 -0
- data/lib/fine_print/security_transgression.rb +1 -2
- data/lib/fine_print/utilities.rb~ +26 -0
- data/lib/fine_print/version.rb +1 -1
- data/lib/fine_print.rb +89 -42
- data/lib/fine_print.rb~ +89 -41
- data/lib/tasks/fine_print_tasks.rake +11 -8
- data/spec/controllers/contracts_controller_spec.rb +222 -0
- data/spec/controllers/contracts_controller_spec.rb~ +224 -0
- data/spec/controllers/home_controller_spec.rb +25 -0
- data/spec/controllers/home_controller_spec.rb~ +25 -0
- data/spec/controllers/signatures_controller_spec.rb +46 -0
- data/spec/controllers/signatures_controller_spec.rb~ +46 -0
- data/spec/dummy/README.md +1 -1
- data/spec/dummy/app/controllers/dummy_models_controller.rb +2 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb~ +29 -0
- data/spec/dummy/app/helpers/application_helper.rb +13 -0
- data/spec/dummy/app/models/dummy_user.rb +3 -0
- data/spec/dummy/app/models/dummy_user.rb~ +4 -0
- data/spec/dummy/app/models/user.rb~ +78 -0
- data/spec/dummy/config/application.rb +2 -2
- data/spec/dummy/config/application.rb~ +60 -0
- data/spec/dummy/config/initializers/fine_print.rb +36 -0
- data/spec/dummy/config/initializers/fine_print.rb~ +36 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb~ +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb~ +14 -0
- data/spec/dummy/config/routes.rb +1 -2
- data/spec/dummy/config/routes.rb~ +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1_create_dummy_users.rb +9 -0
- data/spec/dummy/db/migrate/1_create_dummy_users.rb~ +8 -0
- data/spec/dummy/db/schema.rb +20 -12
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1635 -0
- data/spec/dummy/log/test.log +46188 -0
- data/spec/factories/contract.rb +25 -0
- data/spec/factories/contract.rb~ +26 -0
- data/spec/factories/dummy_user.rb +4 -0
- data/spec/factories/dummy_user.rb~ +6 -0
- data/spec/factories/signature.rb +6 -0
- data/spec/factories/signature.rb~ +8 -0
- data/spec/factories/user.rb~ +6 -0
- data/spec/fine_print_spec.rb~ +15 -4
- data/spec/lib/fine_print/controller_additions_spec.rb +20 -0
- data/spec/lib/fine_print/controller_additions_spec.rb~ +20 -0
- data/spec/lib/fine_print_spec.rb +47 -0
- data/spec/lib/fine_print_spec.rb~ +47 -0
- data/spec/models/contract_spec.rb +79 -0
- data/spec/models/contract_spec.rb~ +80 -0
- data/spec/models/signature_spec.rb +28 -0
- data/spec/models/signature_spec.rb~ +28 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/spec_helper.rb~ +32 -0
- data/spec/test_helper.rb~ +15 -0
- metadata +153 -91
- data/app/assets/javascripts/fine_print/agreements.js +0 -19
- data/app/assets/javascripts/fine_print/agreements.js~ +0 -19
- data/app/assets/javascripts/fine_print/application.js~ +0 -5
- data/app/assets/javascripts/fine_print/dialog.js +0 -2
- data/app/assets/javascripts/fine_print/dialog.js~ +0 -2
- data/app/assets/javascripts/fine_print/user_agreements.js +0 -20
- data/app/assets/javascripts/fine_print/user_agreements.js~ +0 -20
- data/app/assets/stylesheets/fine_print/agreements.css +0 -11
- data/app/assets/stylesheets/fine_print/agreements.css~ +0 -11
- data/app/assets/stylesheets/fine_print/application.css~ +0 -60
- data/app/assets/stylesheets/fine_print/user_agreements.css~ +0 -3
- data/app/assets/stylesheets/scaffold.css~ +0 -56
- data/app/controllers/fine_print/agreements_controller.rb +0 -114
- data/app/controllers/fine_print/agreements_controller.rb~ +0 -113
- data/app/controllers/fine_print/user_agreements_controller.rb +0 -63
- data/app/controllers/fine_print/user_agreements_controller.rb~ +0 -63
- data/app/models/fine_print/agreement.rb +0 -50
- data/app/models/fine_print/agreement.rb~ +0 -50
- data/app/models/fine_print/user_agreement.rb +0 -19
- data/app/models/fine_print/user_agreement.rb~ +0 -21
- data/app/views/fine_print/agreements/_agreement.html.erb +0 -77
- data/app/views/fine_print/agreements/_agreement.html.erb~ +0 -77
- data/app/views/fine_print/agreements/_dialog.html.erb +0 -27
- data/app/views/fine_print/agreements/_dialog.html.erb~ +0 -27
- data/app/views/fine_print/agreements/_form.html.erb +0 -51
- data/app/views/fine_print/agreements/_form.html.erb~ +0 -51
- data/app/views/fine_print/agreements/edit.html.erb +0 -8
- data/app/views/fine_print/agreements/edit.html.erb~ +0 -8
- data/app/views/fine_print/agreements/index.html.erb +0 -32
- data/app/views/fine_print/agreements/index.html.erb~ +0 -32
- data/app/views/fine_print/agreements/new.html.erb +0 -7
- data/app/views/fine_print/agreements/new.html.erb~ +0 -7
- data/app/views/fine_print/agreements/new_version.html.erb +0 -7
- data/app/views/fine_print/agreements/new_version.html.erb~ +0 -7
- data/app/views/fine_print/agreements/show.html.erb +0 -15
- data/app/views/fine_print/agreements/show.html.erb~ +0 -14
- data/app/views/fine_print/user_agreements/cancel.js.erb +0 -1
- data/app/views/fine_print/user_agreements/cancel.js.erb~ +0 -2
- data/app/views/fine_print/user_agreements/create.js.erb +0 -2
- data/app/views/fine_print/user_agreements/create.js.erb~ +0 -2
- data/app/views/fine_print/user_agreements/index.html.erb +0 -25
- data/app/views/fine_print/user_agreements/index.html.erb~ +0 -25
- data/db/migrate/0_create_fine_print_agreements.rb~ +0 -22
- data/db/migrate/0_install.rb +0 -28
- data/db/migrate/0_install.rb~ +0 -28
- data/lib/fine_print/agreements_helper.rb +0 -13
- data/lib/fine_print/agreements_helper.rb~ +0 -11
- data/lib/fine_print/fine_print_agreement.rb +0 -26
- data/lib/fine_print/fine_print_agreement.rb~ +0 -26
- data/lib/fine_print/require_agreement.rb~ +0 -22
- data/lib/fine_print/security_transgression.rb~ +0 -3
- data/lib/fine_print/version.rb~ +0 -3
- data/lib/tasks/fine_print_tasks.rake~ +0 -42
- data/spec/dummy/README.md~ +0 -3
- data/spec/fine_print_spec.rb +0 -7
- data/spec/minitest_helper.rb +0 -12
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module FinePrint
|
4
|
+
describe SignaturesController do
|
5
|
+
routes { FinePrint::Engine.routes }
|
6
|
+
|
7
|
+
before do
|
8
|
+
setup_controller_spec
|
9
|
+
@signature = FactoryGirl.create(:signature)
|
10
|
+
@signature.reload
|
11
|
+
end
|
12
|
+
|
13
|
+
it "won't get index unless authorized" do
|
14
|
+
get :index, :use_route => :fine_print
|
15
|
+
assert_redirected_to FinePrint.redirect_path
|
16
|
+
|
17
|
+
sign_in @user
|
18
|
+
get :index, :use_route => :fine_print
|
19
|
+
assert_redirected_to FinePrint.redirect_path
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'must get index if authorized' do
|
23
|
+
sign_in @admin
|
24
|
+
get :index, :use_route => :fine_print
|
25
|
+
assert_response :success
|
26
|
+
end
|
27
|
+
|
28
|
+
it "won't destroy unless authorized" do
|
29
|
+
delete :destroy, :id => @signature.id, :use_route => :fine_print
|
30
|
+
assert_redirected_to FinePrint.redirect_path
|
31
|
+
expect(Signature.find(@signature.id)).to eq @signature
|
32
|
+
|
33
|
+
sign_in @user
|
34
|
+
delete :destroy, :id => @signature.id, :use_route => :fine_print
|
35
|
+
assert_redirected_to FinePrint.redirect_path
|
36
|
+
expect(Signature.find(@signature.id)).to eq @signature
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'must destroy if authorized' do
|
40
|
+
sign_in @admin
|
41
|
+
delete :destroy, :id => @signature.id, :use_route => :fine_print
|
42
|
+
assert_redirected_to signatures_path
|
43
|
+
expect(Signature.find_by_id(@signature.id)).to be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module FinePrint
|
4
|
+
describe SignaturesController do
|
5
|
+
routes { FinePrint::Engine.routes }
|
6
|
+
|
7
|
+
before do
|
8
|
+
setup_controller_spec
|
9
|
+
@signature = FactoryGirl.create(:signature)
|
10
|
+
@signature.reload
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'won''t get index unless authorized' do
|
14
|
+
get :index, :use_route => :fine_print
|
15
|
+
assert_redirected_to FinePrint.redirect_path
|
16
|
+
|
17
|
+
sign_in @user
|
18
|
+
get :index, :use_route => :fine_print
|
19
|
+
assert_redirected_to FinePrint.redirect_path
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'must get index if authorized' do
|
23
|
+
sign_in @admin
|
24
|
+
get :index, :use_route => :fine_print
|
25
|
+
assert_response :success
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'won''t destroy unless authorized' do
|
29
|
+
delete :destroy, :id => @signature.id, :use_route => :fine_print
|
30
|
+
assert_redirected_to FinePrint.redirect_path
|
31
|
+
expect(Signature.find(@signature.id)).to eq @signature
|
32
|
+
|
33
|
+
sign_in @user
|
34
|
+
delete :destroy, :id => @signature.id, :use_route => :fine_print
|
35
|
+
assert_redirected_to FinePrint.redirect_path
|
36
|
+
expect(Signature.find(@signature.id)).to eq @signature
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'must destroy if authorized' do
|
40
|
+
sign_in @admin
|
41
|
+
delete :destroy, :id => @signature.id, :use_route => :fine_print
|
42
|
+
assert_redirected_to signatures_path
|
43
|
+
expect(Signature.find_by_id(@signature.id)).to be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/dummy/README.md
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
class DummyModelsController < ActionController::Base
|
2
|
+
before_filter :get_dummy
|
3
|
+
|
4
|
+
def hide
|
5
|
+
render :show
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
commontator_thread_show(@dummy_model)
|
10
|
+
end
|
11
|
+
|
12
|
+
def url_options
|
13
|
+
return Hash.new if request.nil?
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def view_context
|
18
|
+
view_context = view_context_class.new
|
19
|
+
view_context.view_paths = view_paths
|
20
|
+
view_context.controller = self
|
21
|
+
view_context
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def get_dummy
|
27
|
+
@dummy_model = DummyModel.find(params[:id])
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module FinePrint
|
2
|
+
class User < ActiveRecord::Base
|
3
|
+
has_many :signatures, :inverse_of => :contract
|
4
|
+
|
5
|
+
has_many :same_name, :class_name => 'Contract', :primary_key => :name, :foreign_key => :name
|
6
|
+
|
7
|
+
attr_accessible :content, :title, :name
|
8
|
+
|
9
|
+
before_validation :downcase_name
|
10
|
+
|
11
|
+
validates_presence_of :name, :title, :content
|
12
|
+
validates_format_of :name, :with => /\A\w+\z/
|
13
|
+
validates_uniqueness_of :version, :scope => :name, :case_sensitive => false
|
14
|
+
|
15
|
+
default_scope order(:name, 'version DESC')
|
16
|
+
|
17
|
+
scope :published, where(arel_table[:version].not_eq(nil))
|
18
|
+
scope :latest, published
|
19
|
+
.joins(:same_name)
|
20
|
+
.group(:id)
|
21
|
+
.having(:version => arel_table.alias(:same_names_fine_print_contracts)[:version]
|
22
|
+
.maximum.tap{|mvq| mvq.alias = nil})
|
23
|
+
|
24
|
+
def is_published?
|
25
|
+
!version.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def is_latest?
|
29
|
+
is_published? && version == same_name.maximum(:version)
|
30
|
+
end
|
31
|
+
|
32
|
+
def sign(user)
|
33
|
+
FinePrint.sign_contract(self, user)
|
34
|
+
end
|
35
|
+
|
36
|
+
def signed_by?(user)
|
37
|
+
FinePrint.signed_contract?(self, user)
|
38
|
+
end
|
39
|
+
|
40
|
+
def publish
|
41
|
+
self.version = (same_name.published.first.try(:version) || 0) + 1
|
42
|
+
save
|
43
|
+
end
|
44
|
+
|
45
|
+
def unpublish
|
46
|
+
self.version = nil
|
47
|
+
save
|
48
|
+
end
|
49
|
+
|
50
|
+
def draft_copy
|
51
|
+
dup.tap{|contract| contract.version = nil}
|
52
|
+
end
|
53
|
+
|
54
|
+
##################
|
55
|
+
# Access Control #
|
56
|
+
##################
|
57
|
+
|
58
|
+
def can_be_updated?
|
59
|
+
signatures.empty?
|
60
|
+
end
|
61
|
+
|
62
|
+
def can_be_published?
|
63
|
+
signatures.empty? && !is_published?
|
64
|
+
end
|
65
|
+
|
66
|
+
def can_be_unpublished?
|
67
|
+
signatures.empty? && is_latest?
|
68
|
+
end
|
69
|
+
|
70
|
+
alias_method :can_be_destroyed?, :can_be_updated?
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
def downcase_name
|
75
|
+
self.name = name.downcase
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
|
|
3
3
|
require 'rails/all'
|
4
4
|
|
5
5
|
Bundler.require
|
6
|
-
require
|
6
|
+
require 'fine_print'
|
7
7
|
|
8
8
|
module Dummy
|
9
9
|
class Application < Rails::Application
|
@@ -30,7 +30,7 @@ module Dummy
|
|
30
30
|
# config.i18n.default_locale = :de
|
31
31
|
|
32
32
|
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
-
config.encoding =
|
33
|
+
config.encoding = 'utf-8'
|
34
34
|
|
35
35
|
# Configure sensitive parameters which will be filtered from the log file.
|
36
36
|
config.filter_parameters += [:password]
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require 'fine_print'
|
7
|
+
require 'devise'
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
16
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
17
|
+
|
18
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
19
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
20
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
21
|
+
|
22
|
+
# Activate observers that should always be running.
|
23
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
24
|
+
|
25
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
26
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
27
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
28
|
+
|
29
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
30
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
31
|
+
# config.i18n.default_locale = :de
|
32
|
+
|
33
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
34
|
+
config.encoding = 'utf-8'
|
35
|
+
|
36
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
37
|
+
config.filter_parameters += [:password]
|
38
|
+
|
39
|
+
# Enable escaping HTML in JSON.
|
40
|
+
config.active_support.escape_html_entities_in_json = true
|
41
|
+
|
42
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
43
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
44
|
+
# like if you have constraints or database-specific column types
|
45
|
+
# config.active_record.schema_format = :sql
|
46
|
+
|
47
|
+
# Enforce whitelist mode for mass assignment.
|
48
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
49
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
50
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
51
|
+
config.active_record.whitelist_attributes = true
|
52
|
+
|
53
|
+
# Enable the asset pipeline
|
54
|
+
config.assets.enabled = true
|
55
|
+
|
56
|
+
# Version of your assets, change this if you want to expire all your assets
|
57
|
+
config.assets.version = '1.0'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Change the settings below to suit your needs
|
2
|
+
# All settings are initially set to their default values
|
3
|
+
FinePrint.configure do |config|
|
4
|
+
# Engine Configuration
|
5
|
+
|
6
|
+
# Name of the ApplicationController helper method that returns the current user.
|
7
|
+
# Default: 'current_user'
|
8
|
+
config.current_user_method = 'current_user'
|
9
|
+
|
10
|
+
# Proc called with user as argument that should return true if and only if the user is an admin.
|
11
|
+
# Admins can create and edit agreements and terminate accepted agreements.
|
12
|
+
# Default: lambda { |user| false } (no admins)
|
13
|
+
config.user_admin_proc = lambda { |user| user.is_admin }
|
14
|
+
|
15
|
+
# Proc that returns true if and only if the provided user is logged in.
|
16
|
+
# In many systems, a non-logged-in user is represented by nil.
|
17
|
+
# However, some systems use something like an AnonymousUser class to represent this state.
|
18
|
+
# This proc is mostly used to help the developer realize that they should only be asking
|
19
|
+
# signed in users to sign contracts; without this, developers would get a cryptic SQL error.
|
20
|
+
# Default: lambda { |user| !user.nil? }
|
21
|
+
config.user_signed_in_proc = lambda { |user| !user.nil? }
|
22
|
+
|
23
|
+
# Path to redirect users to when an error occurs (e.g. permission denied on admin pages).
|
24
|
+
# Default: '/'
|
25
|
+
config.redirect_path = '/'
|
26
|
+
|
27
|
+
# Signature (fine_print_get_signatures) Configuration
|
28
|
+
|
29
|
+
# Path to redirect users to when they need to agree to contract(s).
|
30
|
+
# A list of contract names that must be agreed to will be available in the 'contracts' parameter.
|
31
|
+
# Your code doesn't have to deal with all of them at once, e.g. you can get
|
32
|
+
# the user to agree to the first one and then they'll just eventually be
|
33
|
+
# redirected back to this page with the remaining contract names.
|
34
|
+
# Default: '/'
|
35
|
+
config.pose_contracts_path = '/'
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Change the settings below to suit your needs
|
2
|
+
# All settings are initially set to their default values
|
3
|
+
FinePrint.configure do |config|
|
4
|
+
# Engine Configuration
|
5
|
+
|
6
|
+
# Name of the ApplicationController helper method that returns the current user.
|
7
|
+
# Default: 'current_user'
|
8
|
+
config.current_user_method = 'current_user'
|
9
|
+
|
10
|
+
# Proc called with user as argument that should return true if and only if the user is an admin.
|
11
|
+
# Admins can create and edit agreements and terminate accepted agreements.
|
12
|
+
# Default: lambda { |user| false } (no admins)
|
13
|
+
config.user_admin_proc = lambda { |user| false }
|
14
|
+
|
15
|
+
# Proc that returns true if and only if the provided user is logged in.
|
16
|
+
# In many systems, a non-logged-in user is represented by nil.
|
17
|
+
# However, some systems use something like an AnonymousUser class to represent this state.
|
18
|
+
# This proc is mostly used to help the developer realize that they should only be asking
|
19
|
+
# signed in users to sign contracts; without this, developers would get a cryptic SQL error.
|
20
|
+
# Default: lambda { |user| !user.nil? }
|
21
|
+
config.user_signed_in_proc = lambda { |user| !user.nil? }
|
22
|
+
|
23
|
+
# Path to redirect users to when an error occurs (e.g. permission denied on admin pages).
|
24
|
+
# Default: '/'
|
25
|
+
config.redirect_path = '/'
|
26
|
+
|
27
|
+
# Signature (fine_print_get_signatures) Configuration
|
28
|
+
|
29
|
+
# Path to redirect users to when they need to agree to contract(s).
|
30
|
+
# A list of contract names that must be agreed to will be available in the 'contracts' parameter.
|
31
|
+
# Your code doesn't have to deal with all of them at once, e.g. you can get
|
32
|
+
# the user to agree to the first one and then they'll just eventually be
|
33
|
+
# redirected back to this page with the remaining contract names.
|
34
|
+
# Default: '/'
|
35
|
+
config.pose_contracts_path = '/'
|
36
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
Dummy::Application.config.session_store :cookie_store, key
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
4
|
|
5
5
|
# Use the database for sessions instead of the cookie-based default,
|
6
6
|
# which shouldn't be used to store highly confidential information
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
7
|
ActiveSupport.on_load(:action_controller) do
|
8
|
-
wrap_parameters format
|
8
|
+
wrap_parameters :format => [:json]
|
9
9
|
end
|
10
10
|
|
11
11
|
# Disable root element in JSON by default.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
data/spec/dummy/config/routes.rb
CHANGED
Binary file
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,26 +11,34 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
14
|
+
ActiveRecord::Schema.define(:version => 1) do
|
15
15
|
|
16
|
-
create_table "
|
17
|
-
t.
|
18
|
-
t.
|
16
|
+
create_table "dummy_users", :force => true do |t|
|
17
|
+
t.boolean "is_admin", :default => false, :null => false
|
18
|
+
t.datetime "created_at", :null => false
|
19
|
+
t.datetime "updated_at", :null => false
|
20
|
+
end
|
21
|
+
|
22
|
+
create_table "fine_print_contracts", :force => true do |t|
|
23
|
+
t.string "name", :null => false
|
19
24
|
t.integer "version"
|
25
|
+
t.string "title", :null => false
|
26
|
+
t.text "content", :null => false
|
20
27
|
t.datetime "created_at", :null => false
|
21
28
|
t.datetime "updated_at", :null => false
|
22
29
|
end
|
23
30
|
|
24
|
-
add_index "
|
31
|
+
add_index "fine_print_contracts", ["name", "version"], :name => "index_fine_print_contracts_on_name_and_version", :unique => true
|
25
32
|
|
26
|
-
create_table "
|
27
|
-
t.integer "
|
28
|
-
t.integer "
|
29
|
-
t.
|
30
|
-
t.datetime "
|
33
|
+
create_table "fine_print_signatures", :force => true do |t|
|
34
|
+
t.integer "contract_id", :null => false
|
35
|
+
t.integer "user_id", :null => false
|
36
|
+
t.string "user_type", :null => false
|
37
|
+
t.datetime "created_at", :null => false
|
38
|
+
t.datetime "updated_at", :null => false
|
31
39
|
end
|
32
40
|
|
33
|
-
add_index "
|
34
|
-
add_index "
|
41
|
+
add_index "fine_print_signatures", ["contract_id"], :name => "index_fine_print_signatures_on_contract_id"
|
42
|
+
add_index "fine_print_signatures", ["user_id", "user_type", "contract_id"], :name => "index_fine_print_s_on_u_id_and_u_type_and_c_id", :unique => true
|
35
43
|
|
36
44
|
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|