fine_print 3.1.0 → 4.0.0

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 +5 -5
  2. data/README.md +6 -6
  3. data/app/controllers/fine_print/application_controller.rb +1 -1
  4. data/app/controllers/fine_print/contracts_controller.rb +1 -1
  5. data/app/controllers/fine_print/signatures_controller.rb +5 -5
  6. data/app/models/fine_print/contract.rb +5 -4
  7. data/app/views/fine_print/signatures/_form.html.erb +2 -1
  8. data/config/initializers/fine_print.rb +14 -19
  9. data/db/migrate/0_install_fine_print.rb +1 -1
  10. data/db/migrate/1_add_implicit_signatures.rb +1 -1
  11. data/lib/fine_print/action_controller/base.rb +5 -5
  12. data/lib/fine_print/engine.rb +5 -5
  13. data/lib/fine_print/version.rb +1 -1
  14. data/lib/fine_print.rb +24 -13
  15. data/spec/controllers/contracts_controller_spec.rb +22 -22
  16. data/spec/controllers/signatures_controller_spec.rb +11 -11
  17. data/spec/dummy/Rakefile +2 -2
  18. data/spec/dummy/app/assets/config/manifest.js +4 -0
  19. data/spec/dummy/app/assets/javascripts/application.js +5 -3
  20. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  21. data/spec/dummy/app/assets/stylesheets/application.css +6 -4
  22. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  23. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  24. data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -1
  25. data/spec/dummy/app/jobs/application_job.rb +2 -0
  26. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  27. data/spec/dummy/app/models/application_record.rb +3 -0
  28. data/spec/dummy/app/models/dummy_user.rb +1 -1
  29. data/spec/dummy/app/views/layouts/application.html.erb +10 -10
  30. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  31. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  32. data/spec/dummy/bin/bundle +1 -1
  33. data/spec/dummy/bin/rails +1 -1
  34. data/spec/dummy/bin/setup +36 -0
  35. data/spec/dummy/bin/update +31 -0
  36. data/spec/dummy/bin/yarn +11 -0
  37. data/spec/dummy/config/application.rb +7 -13
  38. data/spec/dummy/config/boot.rb +3 -3
  39. data/spec/dummy/config/cable.yml +10 -0
  40. data/spec/dummy/config/database.yml +9 -9
  41. data/spec/dummy/config/environment.rb +2 -2
  42. data/spec/dummy/config/environments/development.rb +37 -5
  43. data/spec/dummy/config/environments/production.rb +43 -29
  44. data/spec/dummy/config/environments/test.rb +14 -4
  45. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  46. data/spec/dummy/config/initializers/assets.rb +14 -0
  47. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  48. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  49. data/spec/dummy/config/initializers/fine_print.rb +1 -2
  50. data/spec/dummy/config/initializers/mime_types.rb +0 -1
  51. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
  52. data/spec/dummy/config/locales/en.yml +10 -0
  53. data/spec/dummy/config/puma.rb +34 -0
  54. data/spec/dummy/config/spring.rb +6 -0
  55. data/spec/dummy/config/storage.yml +34 -0
  56. data/spec/dummy/config.ru +2 -1
  57. data/spec/dummy/db/migrate/1000_create_dummy_users.rb +1 -1
  58. data/spec/dummy/db/schema.rb +15 -18
  59. data/spec/dummy/db/test.sqlite3 +0 -0
  60. data/spec/dummy/log/test.log +790 -3835
  61. data/spec/dummy/package.json +5 -0
  62. data/spec/dummy/public/404.html +24 -15
  63. data/spec/dummy/public/422.html +24 -15
  64. data/spec/dummy/public/500.html +23 -14
  65. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  66. data/spec/dummy/public/apple-touch-icon.png +0 -0
  67. data/spec/factories/fine_print/contract.rb +2 -2
  68. data/spec/factories/fine_print/signature.rb +2 -2
  69. data/spec/factories/user.rb +1 -1
  70. data/spec/lib/fine_print_spec.rb +4 -4
  71. data/spec/models/contract_spec.rb +6 -6
  72. data/spec/models/signature_spec.rb +2 -2
  73. data/spec/spec_helper.rb +3 -1
  74. data/spec/support/controller.rb +2 -2
  75. metadata +97 -43
  76. data/spec/dummy/README.md +0 -3
  77. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  78. data/spec/dummy/config/initializers/session_store.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6538ce528adfe5224a637f721b0143e26a91565d
4
- data.tar.gz: 1d9290f91f0e09774fa4f01e29e7fda7784a1b92
2
+ SHA256:
3
+ metadata.gz: b85dc2f146980af79e449e2b6ddf27baf5968df56ebabf1ebf34819f5bcc3b80
4
+ data.tar.gz: dabc834b4c2bdfc7a18bfec22360dfef9a64c76731aa5497257642bb4d69a7eb
5
5
  SHA512:
6
- metadata.gz: 2ed558aad019900366e18fcec4b5f4bda152d094acc6d548396c454b36dd89b57b99f91544c45e54bf110bbf264907c119f0a66e6d823a3c2a755c2bd512b407
7
- data.tar.gz: 3bd49121ba9ebe3d38f0af95f06c7eafc618ed04999f5c21101eee474cef5586124c304c292bdaa5a19e91755840d8069f67c17148f805dbb3b23d68b8b40d4f
6
+ metadata.gz: 1b53d9d64e3820e6842166b21e44837a02d5d526d6b107cd4831f199b36efed791646d2158227852397d701ac722dc64ed50abffe25d23918179949d103770af
7
+ data.tar.gz: b3990f072bf7c6bde599019f8fdaa09e9cf43bac17559bb955bc75b6ce4455ffa3e0e8088aa87acacfb7af40de66a7b05f48f4bbb7ecaafdb97cd66da6c670ed
data/README.md CHANGED
@@ -80,11 +80,11 @@ this proc to return `true` for your admins.
80
80
  ## Usage
81
81
 
82
82
  You can choose to check if users signed contracts either
83
- as a before_filter or inside your controller actions.
83
+ as a before_action or inside your controller actions.
84
84
 
85
- ### Option 1 - As a before_filter
85
+ ### Option 1 - As a before_action
86
86
 
87
- If you choose to have FinePrint work like a before_filter, you can user the following class methods, which are automatically added to your controllers:
87
+ If you choose to have FinePrint work like a before_action, you can user the following class methods, which are automatically added to your controllers:
88
88
 
89
89
  ```rb
90
90
  fine_print_require(contract_names..., options_hash)
@@ -100,7 +100,7 @@ These methods take a list of contract names to check, along with an options hash
100
100
  If no contract names are provided, or if :all is passed to one of the methods,
101
101
  ALL existing contracts will be required or skipped.
102
102
 
103
- The options hash can include any options you could pass to a `before_filter`,
103
+ The options hash can include any options you could pass to a `before_action`,
104
104
  e.g. `only` and `except`, plus the FinePrint-specific option
105
105
  `redirect_to_contracts_proc`, which is a proc that controls
106
106
  where users are redirected to in order to sign contracts.
@@ -142,7 +142,7 @@ fine_print_require(contract_names..., options_hash)
142
142
  fine_print_return
143
143
  ```
144
144
 
145
- - `fine_print_require` works just like the before_filter version and will
145
+ - `fine_print_require` works just like the before_action version and will
146
146
  redirect the user if they haven't signed one or more of the given contracts
147
147
  - `fine_print_return` can be used to return from a redirect
148
148
  made by `fine_print_require`
@@ -177,7 +177,7 @@ If you require more explanation about these methods and their arguments, check t
177
177
 
178
178
  ### Redirecting users back
179
179
 
180
- Regardless if you use the class before_filter or instance methods,
180
+ Regardless if you use the class before_action or instance methods,
181
181
  after your contract is signed you can use the `fine_print_return` controller
182
182
  instance method to send the user back to the place where they came from.
183
183
 
@@ -4,7 +4,7 @@ module FinePrint
4
4
  class ApplicationController < ::ActionController::Base
5
5
  respond_to :html
6
6
 
7
- before_filter :get_user, :can_manage
7
+ before_action :get_user, :can_manage
8
8
 
9
9
  layout FinePrint.config.layout
10
10
 
@@ -2,7 +2,7 @@ module FinePrint
2
2
  class ContractsController < FinePrint::ApplicationController
3
3
  include FinePrint::ApplicationHelper
4
4
 
5
- before_filter :get_contract, except: [:index, :new, :create]
5
+ before_action :get_contract, except: [:index, :new, :create]
6
6
 
7
7
  def index
8
8
  @contracts = Contract.includes(:signatures).all.to_a.group_by(&:name)
@@ -2,10 +2,10 @@ module FinePrint
2
2
  class SignaturesController < FinePrint::ApplicationController
3
3
  include FinePrint::ApplicationHelper
4
4
 
5
- skip_before_filter :can_manage, only: [:new, :create]
5
+ skip_before_action :can_manage, only: [:new, :create]
6
6
  fine_print_skip only: [:new, :create]
7
- before_filter :can_sign, only: [:new, :create]
8
- before_filter :get_contract, only: [:index, :new, :create]
7
+ before_action :can_sign, only: [:new, :create]
8
+ before_action :get_contract, only: [:index, :new, :create]
9
9
 
10
10
  def index
11
11
  @signatures = @contract.signatures
@@ -28,14 +28,14 @@ module FinePrint
28
28
 
29
29
  @signature.user = @user
30
30
  @signature.contract = @contract
31
-
31
+
32
32
  if @signature.save
33
33
  fine_print_return
34
34
  else
35
35
  render action: 'new', alert: merge_errors_for(@signature)
36
36
  end
37
37
  end
38
-
38
+
39
39
  def destroy
40
40
  @signature = Signature.find(params[:id])
41
41
 
@@ -16,11 +16,11 @@ module FinePrint
16
16
  case_sensitive: false},
17
17
  allow_nil: true
18
18
 
19
- default_scope lambda { order{[name.asc, version.desc]} }
19
+ default_scope lambda { ordering{[name.asc, version.desc]} }
20
20
 
21
- scope :published, lambda { where{version != nil} }
22
- scope :latest, lambda { joins(:same_name).group{id}
23
- .having{version == max(same_name.version)} }
21
+ scope :published, lambda { where.has{version != nil} }
22
+ scope :latest, lambda { joins(:same_name).grouping{id}
23
+ .when_having{version == max(same_name.version)} }
24
24
 
25
25
  def is_published?
26
26
  !version.nil?
@@ -63,6 +63,7 @@ module FinePrint
63
63
  def no_signatures
64
64
  return if signatures.empty?
65
65
  errors.add(:base, I18n.t('fine_print.contract.errors.already_signed'))
66
+ throw(:abort)
66
67
  false
67
68
  end
68
69
 
@@ -24,6 +24,7 @@
24
24
 
25
25
  <div class='actions'>
26
26
  <%= f.submit t('fine_print.signature.actions.sign'),
27
- class: 'fine_print submit' %>
27
+ class: 'fine_print submit',
28
+ data: { disable_with: 'Please wait...' } %>
28
29
  </div>
29
30
  <% end %>
@@ -11,8 +11,8 @@ FinePrint.configure do |config|
11
11
  config.helpers = []
12
12
 
13
13
  # Proc called with a controller as self. Returns the current user.
14
- # Default: lambda { current_user }
15
- config.current_user_proc = lambda { current_user }
14
+ # Default: -> { current_user }
15
+ config.current_user_proc = -> { current_user }
16
16
 
17
17
  # Proc called with a user as argument and a controller as self.
18
18
  # This proc is called when a user tries to access FinePrint's controllers.
@@ -20,8 +20,8 @@ FinePrint.configure do |config|
20
20
  # or admin. Contract managers can create and edit agreements and terminate
21
21
  # accepted agreements. The default renders 403 Forbidden for all users.
22
22
  # Note: Proc must account for nil users, if current_user_proc returns nil.
23
- # Default: lambda { |user| head(:forbidden) }
24
- config.authenticate_manager_proc = lambda { |user| head(:forbidden) }
23
+ # Default: ->(user) { head(:forbidden) }
24
+ config.authenticate_manager_proc = ->(user) { head(:forbidden) }
25
25
 
26
26
  # Proc called with a user as argument and a controller as self.
27
27
  # This proc is called before FinePrint determines if contracts need to be
@@ -29,12 +29,11 @@ FinePrint.configure do |config|
29
29
  # potentially call the redirect_to_contracts_proc with the user as argument.
30
30
  # If it returns false, renders or redirects, FinePrint will stop its checks.
31
31
  # Note that returning false will allow the user to proceed without signing
32
- # contracts, unless another before_filter renders or redirects (to a login
32
+ # contracts, unless another before_action renders or redirects (to a login
33
33
  # page, for example). The default renders 401 Unauthorized for nil users and
34
34
  # checks all others for contracts to be signed.
35
- # Default: lambda { |user| !user.nil? || head(:unauthorized) }
36
- config.authenticate_user_proc = lambda { |user| !user.nil? || \
37
- head(:unauthorized) }
35
+ # Default: ->(user) { !user.nil? || head(:unauthorized) }
36
+ config.authenticate_user_proc = ->(user) { !user.nil? || head(:unauthorized) }
38
37
 
39
38
  # Controller Configuration
40
39
  # Can be set in this initializer or passed as options to `fine_print_require`
@@ -46,19 +45,15 @@ FinePrint.configure do |config|
46
45
  # The `contracts` argument contains the contracts that need to be signed.
47
46
  # The default redirects users to FinePrint's contract signing views.
48
47
  # The `fine_print_return` method can be used to return from this redirect.
49
- # Default: lambda { |user, contracts|
50
- # redirect_to(fine_print.new_contract_signature_path(
51
- # contract_id: contracts.first.id
52
- # ))
53
- # }
54
- config.redirect_to_contracts_proc = lambda { |user, contracts|
55
- redirect_to(
56
- fine_print.new_contract_signature_path(contract_id: contracts.first.id)
57
- )
58
- }
48
+ # Default: ->(user, contracts) do
49
+ # redirect_to fine_print.new_contract_signature_path(contract_id: contracts.first.id)
50
+ # end
51
+ config.redirect_to_contracts_proc = ->(user, contracts) do
52
+ redirect_to fine_print.new_contract_signature_path(contract_id: contracts.first.id)
53
+ end
59
54
 
60
55
  # Proc called whenever a contract is published, useful if the application
61
56
  # needs to hook into this event and take some action
62
- config.contract_published_proc = lambda { |contract| }
57
+ config.contract_published_proc = ->(contract) { }
63
58
 
64
59
  end
@@ -1,4 +1,4 @@
1
- class InstallFinePrint < ActiveRecord::Migration
1
+ class InstallFinePrint < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :fine_print_contracts do |t|
4
4
  t.string :name, null: false
@@ -1,4 +1,4 @@
1
- class AddImplicitSignatures < ActiveRecord::Migration
1
+ class AddImplicitSignatures < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :fine_print_signatures, :is_implicit,
4
4
  :boolean, null: false, default: false
@@ -67,10 +67,10 @@ module FinePrint
67
67
 
68
68
  module ClassMethods
69
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
70
+ # Adds a before_action to the current controller that will check if the
71
71
  # current user has signed the given contracts and call the sign_proc if appropriate
72
72
  # Options relevant to FinePrint are passed to fine_print_sign, while
73
- # other options are passed to the before_filter
73
+ # other options are passed to the before_action
74
74
  def fine_print_require(*names)
75
75
  options = names.last.is_a?(Hash) ? names.pop : {}
76
76
  f_opts = options.except(*FinePrint::Configuration::CONTROLLER_OPTIONS)
@@ -80,7 +80,7 @@ module FinePrint
80
80
  contract_names = ['all'] if contract_names.empty?
81
81
 
82
82
  class_exec do
83
- before_filter(f_opts) do |controller|
83
+ before_action(f_opts) do |controller|
84
84
  skipped_contract_names = fine_print_skipped_contract_names
85
85
  next if skipped_contract_names.include?('all')
86
86
  contract_names = FinePrint::Contract.all.to_a.collect{|c| c.name}
@@ -95,7 +95,7 @@ module FinePrint
95
95
  # Accepts an array of contract names and an options hash
96
96
  # Excludes the given contracts from the `fine_print_require`
97
97
  # check for this controller and subclasses
98
- # Options are passed to prepend_before_filter
98
+ # Options are passed to prepend_before_action
99
99
  def fine_print_skip(*names)
100
100
  options = names.last.is_a?(Hash) ? names.pop : {}
101
101
 
@@ -104,7 +104,7 @@ module FinePrint
104
104
  contract_names = ['all'] if contract_names.empty?
105
105
 
106
106
  class_exec do
107
- prepend_before_filter(options) do |controller|
107
+ prepend_before_action(options) do |controller|
108
108
  controller.fine_print_skipped_contract_names.push(*contract_names)
109
109
  end
110
110
  end
@@ -1,5 +1,5 @@
1
1
  require 'action_interceptor'
2
- require 'squeel'
2
+ require 'baby_squeel'
3
3
  require 'fine_print/action_controller/base'
4
4
 
5
5
  module FinePrint
@@ -7,16 +7,16 @@ module FinePrint
7
7
  isolate_namespace FinePrint
8
8
 
9
9
  initializer "fine_print.factories",
10
- after: "factory_girl.set_factory_paths" do
11
- FactoryGirl.definition_file_paths << File.join(
10
+ after: "factory_bot.set_factory_paths" do
11
+ FactoryBot.definition_file_paths << File.join(
12
12
  root, 'spec', 'factories', 'fine_print'
13
- ) if defined?(FactoryGirl)
13
+ ) if defined?(FactoryBot)
14
14
  end
15
15
 
16
16
  # http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
17
17
  config.generators do |g|
18
18
  g.test_framework :rspec, fixture: false
19
- g.fixture_replacement :factory_girl, dir: 'spec/factories'
19
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
20
20
  g.assets false
21
21
  g.helper false
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module FinePrint
2
- VERSION = '3.1.0'
2
+ VERSION = '4.0.0'
3
3
  end
data/lib/fine_print.rb CHANGED
@@ -23,8 +23,7 @@ module FinePrint
23
23
  return Contract.find(num) if num
24
24
  contract = Contract.where(name: reference.to_s).published.first
25
25
  return contract if contract
26
- raise ActiveRecord::RecordNotFound,
27
- "Couldn't find Contract with 'name'=#{reference.to_s}"
26
+ raise ActiveRecord::RecordNotFound, "Couldn't find Contract with 'name'=#{reference.to_s}"
28
27
  end
29
28
 
30
29
  # Records that the given user has signed the given contract
@@ -32,13 +31,26 @@ module FinePrint
32
31
  # - contract - can be a Contract object, its ID, or its name (String/Symbol)
33
32
  # - is_implicit - if true, the signature is implicit/assumed/indirectly-acquired
34
33
  # if false, the signature was obtained directly from the user
35
- def self.sign_contract(user, contract, is_implicit = SIGNATURE_IS_EXPLICIT)
36
- contract = get_contract(contract)
37
-
38
- Signature.create do |signature|
39
- signature.user = user
40
- signature.contract = contract
41
- signature.is_implicit = is_implicit
34
+ def self.sign_contract(user, contract, is_implicit = SIGNATURE_IS_EXPLICIT, max_attempts = 3)
35
+ attempts = 0
36
+
37
+ begin
38
+ Signature.transaction(requires_new: true) do
39
+ contract = get_contract(contract)
40
+
41
+ Signature.create do |signature|
42
+ signature.user = user
43
+ signature.contract = contract
44
+ signature.is_implicit = is_implicit
45
+ end
46
+ end
47
+ rescue ActiveRecord::RecordNotUnique => exception
48
+ attempts += 1
49
+ raise exception if attempts >= max_attempts
50
+
51
+ # Simply retry as in https://apidock.com/rails/v4.0.2/ActiveRecord/Relation/find_or_create_by
52
+ # If it already exists, the validations should catch it this time
53
+ retry
42
54
  end
43
55
  end
44
56
 
@@ -50,8 +62,7 @@ module FinePrint
50
62
 
51
63
  contract = get_contract(contract)
52
64
 
53
- contract.signatures.where(user_id: user.id,
54
- user_type: user.class.name).exists?
65
+ contract.signatures.where(user_id: user.id, user_type: user.class.name).exists?
55
66
  end
56
67
 
57
68
  # Returns true iff the given user has signed any version of the given contract
@@ -63,7 +74,7 @@ module FinePrint
63
74
  contract = get_contract(contract)
64
75
 
65
76
  contract.same_name.joins(:signatures).where(
66
- signatures: { user_id: user.id, user_type: user.class.name }
77
+ fine_print_signatures: { user_id: user.id, user_type: user.class.name }
67
78
  ).exists?
68
79
  end
69
80
 
@@ -82,7 +93,7 @@ module FinePrint
82
93
 
83
94
  contracts = latest_published_contracts(conditions)
84
95
  contracts.joins(:signatures).where(
85
- signatures: { user_id: user.id, user_type: user.class.name }
96
+ fine_print_signatures: { user_id: user.id, user_type: user.class.name }
86
97
  )
87
98
  end
88
99
 
@@ -8,7 +8,7 @@ module FinePrint
8
8
  setup_controller_spec
9
9
  end
10
10
 
11
- let!(:contract) { FactoryGirl.create(:fine_print_contract) }
11
+ let!(:contract) { FactoryBot.create(:fine_print_contract) }
12
12
 
13
13
  it "won't get index unless authorized" do
14
14
  get :index
@@ -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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { 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, params: { id: contract.id }
218
218
  expect(response.status).to eq 200
219
219
  expect(assigns(:contract)).not_to be_nil
220
220
  end