fine_print 2.3.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +101 -61
  3. data/Rakefile +2 -2
  4. data/app/controllers/fine_print/application_controller.rb +5 -5
  5. data/app/controllers/fine_print/contracts_controller.rb +15 -12
  6. data/app/controllers/fine_print/signatures_controller.rb +11 -8
  7. data/app/models/fine_print/contract.rb +10 -10
  8. data/app/models/fine_print/signature.rb +9 -8
  9. data/app/views/fine_print/contracts/_form.html.erb +8 -8
  10. data/app/views/fine_print/contracts/edit.html.erb +2 -2
  11. data/app/views/fine_print/contracts/index.html.erb +39 -16
  12. data/app/views/fine_print/contracts/new.html.erb +3 -1
  13. data/app/views/fine_print/contracts/new_version.html.erb +7 -4
  14. data/app/views/fine_print/contracts/show.html.erb +33 -18
  15. data/app/views/fine_print/signatures/_form.html.erb +7 -4
  16. data/app/views/fine_print/signatures/index.html.erb +17 -9
  17. data/app/views/fine_print/signatures/new.html.erb +6 -4
  18. data/config/initializers/fine_print.rb +39 -36
  19. data/config/routes.rb +3 -2
  20. data/db/migrate/0_install_fine_print.rb +8 -8
  21. data/lib/fine_print.rb +40 -55
  22. data/lib/fine_print/action_controller/base.rb +118 -0
  23. data/lib/fine_print/configuration.rb +24 -0
  24. data/lib/fine_print/engine.rb +10 -6
  25. data/lib/fine_print/version.rb +1 -1
  26. data/lib/tasks/fine_print_tasks.rake +4 -2
  27. data/spec/controllers/contracts_controller_spec.rb +22 -22
  28. data/spec/controllers/home_controller_spec.rb +1 -1
  29. data/spec/controllers/signatures_controller_spec.rb +11 -11
  30. data/spec/dummy/app/views/layouts/application.html.erb +2 -1
  31. data/spec/dummy/config/initializers/fine_print.rb +2 -1
  32. data/spec/dummy/config/routes.rb +0 -1
  33. data/spec/dummy/db/migrate/1_create_dummy_users.rb +1 -1
  34. data/spec/dummy/db/test.sqlite3 +0 -0
  35. data/spec/dummy/log/test.log +585 -3119
  36. data/spec/factories/fine_print/contract.rb +1 -1
  37. data/spec/factories/fine_print/signature.rb +2 -2
  38. data/spec/factories/user.rb +1 -1
  39. data/spec/lib/fine_print/action_controller/base_spec.rb +30 -0
  40. data/spec/lib/fine_print_spec.rb +14 -11
  41. data/spec/models/contract_spec.rb +2 -2
  42. data/spec/models/signature_spec.rb +1 -1
  43. metadata +6 -5
  44. data/lib/fine_print/controller_includes.rb +0 -93
  45. data/spec/lib/fine_print/controller_includes_spec.rb +0 -25
data/config/routes.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  FinePrint::Engine.routes.draw do
2
- root :to => 'home#index'
2
+ root to: 'home#index'
3
3
 
4
4
  resources :contracts do
5
- resources :signatures, :only => [:index, :new, :create, :destroy], :shallow => true
5
+ resources :signatures, only: [:index, :new, :create, :destroy],
6
+ shallow: true
6
7
 
7
8
  member do
8
9
  post :new_version
@@ -1,26 +1,26 @@
1
1
  class InstallFinePrint < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :fine_print_contracts do |t|
4
- t.string :name, :null => false
4
+ t.string :name, null: false
5
5
  t.integer :version
6
- t.string :title, :null => false
7
- t.text :content, :null => false
6
+ t.string :title, null: false
7
+ t.text :content, null: false
8
8
 
9
9
  t.timestamps
10
10
  end
11
11
 
12
- add_index :fine_print_contracts, [:name, :version], :unique => true
12
+ add_index :fine_print_contracts, [:name, :version], unique: true
13
13
 
14
14
  create_table :fine_print_signatures do |t|
15
- t.belongs_to :contract, :null => false
16
- t.belongs_to :user, :polymorphic => true, :null => false
15
+ t.belongs_to :contract, null: false
16
+ t.belongs_to :user, polymorphic: true, null: false
17
17
 
18
18
  t.timestamps
19
19
  end
20
20
 
21
21
  add_index :fine_print_signatures, [:user_id, :user_type, :contract_id],
22
- :name => 'index_fine_print_s_on_u_id_and_u_type_and_c_id',
23
- :unique => true
22
+ name: 'index_fine_print_s_on_u_id_and_u_type_and_c_id',
23
+ unique: true
24
24
  add_index :fine_print_signatures, :contract_id
25
25
  end
26
26
  end
data/lib/fine_print.rb CHANGED
@@ -1,42 +1,27 @@
1
+ require 'fine_print/configuration'
1
2
  require 'fine_print/engine'
2
- require 'fine_print/controller_includes'
3
3
 
4
4
  module FinePrint
5
- # Attributes
6
-
7
- # Can be set in initializer only
8
- ENGINE_OPTIONS = [
9
- :current_user_proc,
10
- :can_manage_proc,
11
- :can_sign_proc,
12
- :layout,
13
- :helpers
14
- ]
15
-
16
- # Can be set in initializer or passed as an argument
17
- # to FinePrint controller methods
18
- CONTROLLER_OPTIONS = [
19
- :must_sign_proc
20
- ]
21
-
22
- (ENGINE_OPTIONS + CONTROLLER_OPTIONS).each do |option|
23
- mattr_accessor option
5
+
6
+ def self.config
7
+ @config ||= Configuration.new
24
8
  end
25
-
9
+
26
10
  def self.configure
27
- yield self
11
+ yield config
28
12
  end
29
13
 
30
14
  # Gets a contract, given either the contract object, ID or name
31
- # If given a name, it returns the latest published version of that contract
32
- # - contract - can be a Contract object, its ID, or its name (String/Symbol)
15
+ # If given a name, returns the latest published version of that contract
16
+ # - contract - can be a Contract object, its ID, or its name
33
17
  def self.get_contract(reference)
34
18
  return reference if reference.is_a? Contract
35
19
  num = Integer(reference) rescue nil
36
20
  return Contract.find(num) if num
37
- contract = Contract.where(:name => reference.to_s).published.first
21
+ contract = Contract.where(name: reference.to_s).published.first
38
22
  return contract if contract
39
- raise ActiveRecord::RecordNotFound, "Couldn't find Contract with 'name'=#{reference.to_s}"
23
+ raise ActiveRecord::RecordNotFound,
24
+ "Couldn't find Contract with 'name'=#{reference.to_s}"
40
25
  end
41
26
 
42
27
  # Records that the given user has signed the given contract
@@ -55,55 +40,55 @@ module FinePrint
55
40
  # - user - the user in question
56
41
  # - contract - can be a Contract object, its ID, or its name (String/Symbol)
57
42
  def self.signed_contract?(user, contract)
43
+ return false if user.nil?
44
+
58
45
  contract = get_contract(contract)
59
46
 
60
- contract.signatures.where(:user_id => user.id,
61
- :user_type => user.class.name).exists?
47
+ contract.signatures.where(user_id: user.id,
48
+ user_type: user.class.name).exists?
62
49
  end
63
50
 
64
51
  # Returns true iff the given user has signed any version of the given contract
65
52
  # - user - the user in question
66
53
  # - contract - can be a Contract object, its ID, or its name (String/Symbol)
67
54
  def self.signed_any_version_of_contract?(user, contract)
55
+ return false if user.nil?
56
+
68
57
  contract = get_contract(contract)
69
58
 
70
- contract.same_name.includes(:signatures).any? do |c|
71
- c.signatures.where(:user_id => user.id,
72
- :user_type => user.class.name).exists?
73
- end
59
+ contract.same_name.joins(:signatures).where(
60
+ signatures: { user_id: user.id, user_type: user.class.name }
61
+ ).exists?
74
62
  end
75
63
 
76
- # Converts an array of contract names into an array containing
77
- # the latest contract id for each given name.
78
- def self.contract_names_to_ids(*contract_names)
79
- names = contract_names.flatten
80
- Contract.latest.where(:name => names).pluck(:id)
64
+ # Returns all the latest published contracts that match the given conditions.
65
+ def self.latest_published_contracts(conditions = {})
66
+ Contract.published.latest.where(conditions)
81
67
  end
82
68
 
83
- # Returns an array of ids for the contracts among those given
69
+ # Returns all contracts matching the given conditions
84
70
  # whose latest published version the user has signed.
85
71
  # - user - the user in question
86
- # - contract_ids - contract ids to check
87
- # If no contract ids are provided, all latest contracts are checked
88
- def self.get_signed_contract_ids(user, *contract_ids)
89
- ids = contract_ids.flatten
90
- ids = Contract.published.latest.pluck(:id) if ids.blank?
91
-
92
- Signature.where(:user_id => user.id,
93
- :user_type => user.class.name,
94
- :contract_id => ids).pluck(:contract_id)
72
+ # - conditions - filters the list of contracts to check
73
+ # If no conditions are provided, all latest contracts are checked.
74
+ def self.signed_contracts_for(user, conditions = {})
75
+ return [] if user.nil?
76
+
77
+ contracts = latest_published_contracts(conditions)
78
+ contracts.joins(:signatures).where(
79
+ signatures: { user_id: user.id, user_type: user.class.name }
80
+ )
95
81
  end
96
82
 
97
- # Returns an array of ids for the contracts among those given
83
+ # Returns all contracts matching the given conditions
98
84
  # whose latest published version the user has not signed.
99
85
  # - user - the user in question
100
- # - contract_ids - contract ids to check
101
- # If no contract ids are provided, all latest contracts are checked
102
- def self.get_unsigned_contract_ids(user, *contract_ids)
103
- ids = contract_ids.flatten
104
- ids = Contract.published.latest.pluck(:id) if ids.blank?
105
-
106
- ids - get_signed_contract_ids(user, ids)
86
+ # - conditions - filters the list of contracts to check
87
+ # If no conditions are provided, all latest contracts are checked.
88
+ def self.unsigned_contracts_for(user, conditions = {})
89
+ contracts = latest_published_contracts(conditions)
90
+ signed_contracts = signed_contracts_for(user, conditions)
91
+ contracts - signed_contracts
107
92
  end
108
93
 
109
94
  end
@@ -0,0 +1,118 @@
1
+ module FinePrint
2
+ module ActionController
3
+ module Base
4
+
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ # Accepts an array of contract names and an options hash
10
+ # Checks if the current user has signed the given contracts
11
+ # and calls fine_print_redirect if not
12
+ # Options relevant to FinePrint are passed to fine_print_redirect
13
+ # If no names are given, requires all contracts
14
+ def fine_print_require(*names)
15
+ options = names.last.is_a?(Hash) ? names.pop : {}
16
+ fp_opts = options.slice(*FinePrint::Configuration::CONTROLLER_OPTIONS)
17
+
18
+ # Convert names to an array of Strings
19
+ contract_names = names.flatten.collect{|c| c.to_s}
20
+ contract_names = ['all'] if contract_names.empty?
21
+ contract_names = FinePrint::Contract.all.to_a.collect{|c| c.name}
22
+ .uniq if contract_names.include?('all')
23
+
24
+ user = instance_exec &FinePrint.config.current_user_proc
25
+
26
+ can_sign = instance_exec(user, &FinePrint.config.authenticate_user_proc)
27
+
28
+ return if !can_sign || performed?
29
+
30
+ unsigned_contracts = FinePrint.unsigned_contracts_for(
31
+ user, name: contract_names
32
+ )
33
+
34
+ # Return quietly if all contracts signed
35
+ return if unsigned_contracts.blank?
36
+
37
+ fine_print_redirect(user, unsigned_contracts, fp_opts)
38
+ end
39
+
40
+ # Accepts a user, an array of contract ids to be signed and an options hash
41
+ # Calls the `redirect_to_contracts_proc` with the given parameters
42
+ def fine_print_redirect(user, *contracts)
43
+ options = contracts.last.is_a?(Hash) ? contracts.pop : {}
44
+ contracts = contracts.flatten
45
+
46
+ blk = options[:redirect_to_contracts_proc] || \
47
+ FinePrint.config.redirect_to_contracts_proc
48
+
49
+ # Use action_interceptor to save the current url
50
+ store_url key: :fine_print_return_to
51
+
52
+ instance_exec user, contracts, &blk
53
+ end
54
+
55
+ # Accepts no arguments
56
+ # Redirects the user back to the url they were at before
57
+ # `fine_print_redirect` redirected them
58
+ def fine_print_return
59
+ redirect_back key: :fine_print_return_to
60
+ end
61
+
62
+ protected
63
+
64
+ def fine_print_skipped_contract_names
65
+ @fine_print_skipped_contract_names ||= []
66
+ end
67
+
68
+ module ClassMethods
69
+ # Accepts an array of contract names and an options hash
70
+ # Adds a before_filter to the current controller that will check if the
71
+ # current user has signed the given contracts and call the sign_proc if appropriate
72
+ # Options relevant to FinePrint are passed to fine_print_sign, while
73
+ # other options are passed to the before_filter
74
+ def fine_print_require(*names)
75
+ options = names.last.is_a?(Hash) ? names.pop : {}
76
+ f_opts = options.except(*FinePrint::Configuration::CONTROLLER_OPTIONS)
77
+
78
+ # Convert names to an array of Strings
79
+ contract_names = names.flatten.collect{|c| c.to_s}
80
+ contract_names = ['all'] if contract_names.empty?
81
+
82
+ class_exec do
83
+ before_filter(f_opts) do |controller|
84
+ skipped_contract_names = fine_print_skipped_contract_names
85
+ next if skipped_contract_names.include?('all')
86
+ contract_names = FinePrint::Contract.all.to_a.collect{|c| c.name}
87
+ .uniq if contract_names.include?('all')
88
+ unskipped_contract_names = contract_names - skipped_contract_names
89
+ controller.fine_print_require(unskipped_contract_names, options) \
90
+ unless unskipped_contract_names.empty?
91
+ end
92
+ end
93
+ end
94
+
95
+ # Accepts an array of contract names and an options hash
96
+ # Excludes the given contracts from the `fine_print_require`
97
+ # check for this controller and subclasses
98
+ # Options are passed to prepend_before_filter
99
+ def fine_print_skip(*names)
100
+ options = names.last.is_a?(Hash) ? names.pop : {}
101
+
102
+ # Convert names to an array of Strings
103
+ contract_names = names.flatten.collect{|c| c.to_s}
104
+ contract_names = ['all'] if contract_names.empty?
105
+
106
+ class_exec do
107
+ prepend_before_filter(options) do |controller|
108
+ controller.fine_print_skipped_contract_names.push(*contract_names)
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ end
115
+ end
116
+ end
117
+
118
+ ::ActionController::Base.send :include, FinePrint::ActionController::Base
@@ -0,0 +1,24 @@
1
+ module FinePrint
2
+ class Configuration
3
+ # Attributes
4
+
5
+ # Can be set in initializer only
6
+ ENGINE_OPTIONS = [
7
+ :helpers,
8
+ :layout,
9
+ :authenticate_user_proc,
10
+ :authenticate_manager_proc,
11
+ :current_user_proc
12
+ ]
13
+
14
+ # Can be set in initializer or passed as an argument
15
+ # to FinePrint controller methods
16
+ CONTROLLER_OPTIONS = [
17
+ :redirect_to_contracts_proc
18
+ ]
19
+
20
+ (ENGINE_OPTIONS + CONTROLLER_OPTIONS).each do |option|
21
+ attr_accessor option
22
+ end
23
+ end
24
+ end
@@ -1,24 +1,28 @@
1
1
  require 'action_interceptor'
2
2
  require 'squeel'
3
+ require 'fine_print/action_controller/base'
3
4
 
4
5
  module FinePrint
5
6
  class Engine < ::Rails::Engine
6
7
  isolate_namespace FinePrint
7
8
 
8
- initializer "fine_print.factories", :after => "factory_girl.set_factory_paths" do
9
- FactoryGirl.definition_file_paths << File.join(root, 'spec', 'factories', 'fine_print') \
10
- if defined?(FactoryGirl)
9
+ initializer "fine_print.factories",
10
+ after: "factory_girl.set_factory_paths" do
11
+ FactoryGirl.definition_file_paths << File.join(
12
+ root, 'spec', 'factories', 'fine_print'
13
+ ) if defined?(FactoryGirl)
11
14
  end
12
15
 
13
16
  # http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
14
17
  config.generators do |g|
15
- g.test_framework :rspec, :fixture => false
16
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
18
+ g.test_framework :rspec, fixture: false
19
+ g.fixture_replacement :factory_girl, dir: 'spec/factories'
17
20
  g.assets false
18
21
  g.helper false
19
22
  end
20
23
 
21
24
  # Load subfolders of config/locales as well
22
- config.i18n.load_path += Dir[root.join('config', 'locales', '**', '*.{rb,yml}')]
25
+ config.i18n.load_path += \
26
+ Dir[root.join('config', 'locales', '**', '*.{rb,yml}')]
23
27
  end
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module FinePrint
2
- VERSION = '2.3.1'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -10,7 +10,7 @@ namespace :fine_print do
10
10
  if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
11
11
  print "NOTE: Initializer #{File.basename(file)} from fine_print has been skipped. Initializer with the same name already exists.\n"
12
12
  else
13
- cp file, 'config/initializers', :verbose => false
13
+ cp file, 'config/initializers', verbose: false
14
14
  print "Copied initializer #{File.basename(file)} from fine_print\n"
15
15
  end
16
16
  end
@@ -22,7 +22,9 @@ namespace :fine_print do
22
22
  name = File.basename(path)
23
23
  desc "Copy #{name} from fine_print to application"
24
24
  task name.to_sym do
25
- cp_r File.expand_path("../../../app/#{path}/fine_print", __FILE__), "app/#{path}", :verbose => false
25
+ cp_r File.expand_path("../../../app/#{path}/fine_print", __FILE__),
26
+ "app/#{path}",
27
+ verbose: false
26
28
  print "Copied #{name} from fine_print\n"
27
29
  end
28
30
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module FinePrint
4
- describe ContractsController, :type => :controller do
4
+ describe ContractsController, type: :controller do
5
5
  routes { FinePrint::Engine.routes }
6
6
 
7
7
  before(:each) do
@@ -46,12 +46,12 @@ module FinePrint
46
46
  attributes[:title] = 'Some title'
47
47
  attributes[:content] = 'Some content'
48
48
 
49
- post :create, :contract => :attributes
49
+ post :create, contract: :attributes
50
50
  expect(response.status).to eq 403
51
51
  expect(assigns(:contract)).to be_nil
52
52
 
53
53
  sign_in @user
54
- post :create, :contract => :attributes
54
+ post :create, contract: :attributes
55
55
  expect(response.status).to eq 403
56
56
  expect(assigns(:contract)).to be_nil
57
57
  end
@@ -63,7 +63,7 @@ module FinePrint
63
63
  attributes[:title] = 'Some title'
64
64
  attributes[:content] = 'Some content'
65
65
 
66
- post :create, :contract => attributes
66
+ post :create, contract: attributes
67
67
  expect(response).to redirect_to assigns(:contract)
68
68
  expect(assigns(:contract).errors).to be_empty
69
69
  expect(assigns(:contract).name).to eq 'some_name'
@@ -72,17 +72,17 @@ module FinePrint
72
72
  end
73
73
 
74
74
  it "won't edit unless authorized" do
75
- get :edit, :id => contract.id
75
+ get :edit, id: contract.id
76
76
  expect(response.status).to eq 403
77
77
 
78
78
  sign_in @user
79
- get :edit, :id => contract.id
79
+ get :edit, id: contract.id
80
80
  expect(response.status).to eq 403
81
81
  end
82
82
 
83
83
  it 'must edit if authorized' do
84
84
  sign_in @admin
85
- get :edit, :id => contract.id
85
+ get :edit, id: contract.id
86
86
  expect(response.status).to eq 200
87
87
  end
88
88
 
@@ -95,7 +95,7 @@ module FinePrint
95
95
  title = contract.title
96
96
  content = contract.content
97
97
 
98
- put :update, :id => contract.id, :contract => attributes
98
+ put :update, id: contract.id, contract: attributes
99
99
  expect(response.status).to eq 403
100
100
  contract.reload
101
101
  expect(contract.name).to eq name
@@ -103,7 +103,7 @@ module FinePrint
103
103
  expect(contract.content).to eq content
104
104
 
105
105
  sign_in @user
106
- put :update, :id => contract.id, :contract => attributes
106
+ put :update, id: contract.id, contract: attributes
107
107
  expect(response.status).to eq 403
108
108
  contract.reload
109
109
  expect(contract.name).to eq name
@@ -118,7 +118,7 @@ module FinePrint
118
118
  attributes[:content] = 'Another content'
119
119
 
120
120
  sign_in @admin
121
- put :update, :id => contract.id, :contract => attributes
121
+ put :update, id: contract.id, contract: attributes
122
122
  expect(response).to redirect_to contract
123
123
  contract.reload
124
124
  expect(contract.errors).to be_empty
@@ -128,32 +128,32 @@ module FinePrint
128
128
  end
129
129
 
130
130
  it "won't destroy unless authorized" do
131
- delete :destroy, :id => contract.id
131
+ delete :destroy, id: contract.id
132
132
  expect(response.status).to eq 403
133
133
  expect(Contract.find(contract.id)).to eq contract
134
134
 
135
135
  sign_in @user
136
- delete :destroy, :id => contract.id
136
+ delete :destroy, id: contract.id
137
137
  expect(response.status).to eq 403
138
138
  expect(Contract.find(contract.id)).to eq contract
139
139
  end
140
140
 
141
141
  it 'must destroy if authorized' do
142
142
  sign_in @admin
143
- delete :destroy, :id => contract.id
143
+ delete :destroy, id: contract.id
144
144
  expect(response).to redirect_to contracts_path
145
145
  expect(Contract.find_by_id(contract.id)).to be_nil
146
146
  end
147
147
 
148
148
  it "won't publish unless authorized" do
149
149
  expect(contract.is_published?).to eq false
150
- put :publish, :id => contract.id
150
+ put :publish, id: contract.id
151
151
  expect(response.status).to eq 403
152
152
  contract.reload
153
153
  expect(contract.is_published?).to eq false
154
154
 
155
155
  sign_in @user
156
- put :publish, :id => contract.id
156
+ put :publish, id: contract.id
157
157
  expect(response.status).to eq 403
158
158
  contract.reload
159
159
  expect(contract.is_published?).to eq false
@@ -163,7 +163,7 @@ module FinePrint
163
163
  expect(contract.is_published?).to eq false
164
164
  sign_in @admin
165
165
 
166
- put :publish, :id => contract.id
166
+ put :publish, id: contract.id
167
167
  expect(response).to redirect_to contracts_path
168
168
  contract.reload
169
169
  expect(contract.is_published?).to eq true
@@ -172,13 +172,13 @@ module FinePrint
172
172
  it "won't unpublish unless authorized" do
173
173
  contract.publish
174
174
  expect(contract.is_published?).to eq true
175
- put :unpublish, :id => contract.id
175
+ put :unpublish, id: contract.id
176
176
  expect(response.status).to eq 403
177
177
  contract.reload
178
178
  expect(contract.is_published?).to eq true
179
179
 
180
180
  sign_in @user
181
- put :unpublish, :id => contract.id
181
+ put :unpublish, id: contract.id
182
182
  expect(response.status).to eq 403
183
183
  contract.reload
184
184
  expect(contract.is_published?).to eq true
@@ -189,7 +189,7 @@ module FinePrint
189
189
  expect(contract.is_published?).to eq true
190
190
 
191
191
  sign_in @admin
192
- put :unpublish, :id => contract.id
192
+ put :unpublish, id: contract.id
193
193
  expect(response).to redirect_to contracts_path
194
194
  contract.reload
195
195
  expect(contract.is_published?).to eq false
@@ -199,12 +199,12 @@ module FinePrint
199
199
  contract.publish
200
200
  expect(contract.is_published?).to eq true
201
201
 
202
- post :new_version, :id => contract.id
202
+ post :new_version, id: contract.id
203
203
  expect(response.status).to eq 403
204
204
  expect(assigns(:contract)).to be_nil
205
205
 
206
206
  sign_in @user
207
- post :new_version, :id => contract.id
207
+ post :new_version, id: contract.id
208
208
  expect(response.status).to eq 403
209
209
  expect(assigns(:contract)).to be_nil
210
210
  end
@@ -214,7 +214,7 @@ module FinePrint
214
214
  expect(contract.is_published?).to eq true
215
215
 
216
216
  sign_in @admin
217
- post :new_version, :id => contract.id
217
+ post :new_version, id: contract.id
218
218
  expect(response.status).to eq 200
219
219
  expect(assigns(:contract)).not_to be_nil
220
220
  end