fine_print 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45ee10b15e66cf1763d09c6689c23ed47bda4619
4
- data.tar.gz: ef9c91de28b44343976713634c9b2dd848f181f1
3
+ metadata.gz: eeb6d09c85c20be2b0312861169f2aecd74a85aa
4
+ data.tar.gz: 604d154a8c0a3251e736c9939d93ab4b158e578f
5
5
  SHA512:
6
- metadata.gz: 4410bfd47d1de7de04630157b9454adefe464357167f358fddb8822fb3b3e7d32a62a4fa51fd8e61f5ce3c1b3e137a427c1e5ad7c7a0e3bb60195e348583c930
7
- data.tar.gz: 297761b1255b841580f59494503ae44e5cbdae96559ea242c400395e6b621155ddaeb79a29bd648ea7877cf4a4d1db3c33fc276aa64e739ae0997635a615c759
6
+ metadata.gz: 9814e631196a906b8b1604a132c3d838cc1a00189dd890669fb6677af55879eb6732d421d7397c6c74b77b2c902012e28094873eb82b08e6003020fe85ffe928
7
+ data.tar.gz: 47badd0b0fbcea2f4a23314b08eb155979e2985c0d95d992a65f7553ee084dda6d4ef0cc6573e2f98adb71fdf075eed276fcbd5ae76e48aa446b03e757abc8c5
@@ -22,9 +22,9 @@ FinePrint.configure do |config|
22
22
  # This proc is called to check that the given user is allowed to sign contracts.
23
23
  # Should raise and exception, render or redirect unless the user can sign contracts.
24
24
  # You might want to redirect users to a login page if they are not signed in.
25
- # The default renders 403 Forbidden for nil users.
26
- # Default: lambda { |user| !user.nil? || head(:forbidden) }
27
- config.can_sign_proc = lambda { |user| !user.nil? || head(:forbidden) }
25
+ # The default renders 401 Unauthorized for nil users.
26
+ # Default: lambda { |user| !user.nil? || head(:unauthorized) }
27
+ config.can_sign_proc = lambda { |user| !user.nil? || head(:unauthorized) }
28
28
 
29
29
  # Controller Configuration
30
30
 
@@ -1,3 +1,3 @@
1
1
  module FinePrint
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -11,12 +11,12 @@ module FinePrint
11
11
  let!(:contract) { FactoryGirl.create(:fine_print_contract) }
12
12
 
13
13
  it "won't get index unless authorized" do
14
- expect { get :index, :use_route => :fine_print }
15
- .to raise_error(ActionController::RoutingError)
14
+ get :index, :use_route => :fine_print
15
+ expect(response.status).to eq 403
16
16
 
17
17
  sign_in @user
18
- expect { get :index, :use_route => :fine_print }
19
- .to raise_error(ActionController::RoutingError)
18
+ get :index, :use_route => :fine_print
19
+ expect(response.status).to eq 403
20
20
  end
21
21
 
22
22
  it 'must get index if authorized' do
@@ -26,12 +26,12 @@ module FinePrint
26
26
  end
27
27
 
28
28
  it "won't get new unless authorized" do
29
- expect { get :new, :use_route => :fine_print }
30
- .to raise_error(ActionController::RoutingError)
29
+ get :new, :use_route => :fine_print
30
+ expect(response.status).to eq 403
31
31
 
32
32
  sign_in @user
33
- expect { get :new, :use_route => :fine_print }
34
- .to raise_error(ActionController::RoutingError)
33
+ get :new, :use_route => :fine_print
34
+ expect(response.status).to eq 403
35
35
  end
36
36
 
37
37
  it 'must get new if authorized' do
@@ -45,14 +45,14 @@ module FinePrint
45
45
  attributes[:name] = 'some_name'
46
46
  attributes[:title] = 'Some title'
47
47
  attributes[:content] = 'Some content'
48
-
49
- expect { post :create, :contract => :attributes, :use_route => :fine_print }
50
- .to raise_error(ActionController::RoutingError)
48
+
49
+ post :create, :contract => :attributes, :use_route => :fine_print
50
+ expect(response.status).to eq 403
51
51
  expect(assigns(:contract)).to be_nil
52
52
 
53
53
  sign_in @user
54
- expect { post :create, :contract => :attributes, :use_route => :fine_print }
55
- .to raise_error(ActionController::RoutingError)
54
+ post :create, :contract => :attributes, :use_route => :fine_print
55
+ expect(response.status).to eq 403
56
56
  expect(assigns(:contract)).to be_nil
57
57
  end
58
58
 
@@ -72,12 +72,12 @@ module FinePrint
72
72
  end
73
73
 
74
74
  it "won't edit unless authorized" do
75
- expect { get :edit, :id => contract.id, :use_route => :fine_print }
76
- .to raise_error(ActionController::RoutingError)
75
+ get :edit, :id => contract.id, :use_route => :fine_print
76
+ expect(response.status).to eq 403
77
77
 
78
78
  sign_in @user
79
- expect { get :edit, :id => contract.id, :use_route => :fine_print }
80
- .to raise_error(ActionController::RoutingError)
79
+ get :edit, :id => contract.id, :use_route => :fine_print
80
+ expect(response.status).to eq 403
81
81
  end
82
82
 
83
83
  it 'must edit if authorized' do
@@ -95,18 +95,16 @@ module FinePrint
95
95
  title = contract.title
96
96
  content = contract.content
97
97
 
98
- expect { post :update, :id => contract.id,
99
- :contract => attributes, :use_route => :fine_print }
100
- .to raise_error(ActionController::RoutingError)
98
+ put :update, :id => contract.id, :contract => attributes, :use_route => :fine_print
99
+ expect(response.status).to eq 403
101
100
  contract.reload
102
101
  expect(contract.name).to eq name
103
102
  expect(contract.title).to eq title
104
103
  expect(contract.content).to eq content
105
104
 
106
105
  sign_in @user
107
- expect { post :update, :id => contract.id,
108
- :contract => attributes, :use_route => :fine_print }
109
- .to raise_error(ActionController::RoutingError)
106
+ put :update, :id => contract.id, :contract => attributes, :use_route => :fine_print
107
+ expect(response.status).to eq 403
110
108
  contract.reload
111
109
  expect(contract.name).to eq name
112
110
  expect(contract.title).to eq title
@@ -130,13 +128,13 @@ module FinePrint
130
128
  end
131
129
 
132
130
  it "won't destroy unless authorized" do
133
- expect { delete :destroy, :id => contract.id, :use_route => :fine_print }
134
- .to raise_error(ActionController::RoutingError)
131
+ delete :destroy, :id => contract.id, :use_route => :fine_print
132
+ expect(response.status).to eq 403
135
133
  expect(Contract.find(contract.id)).to eq contract
136
134
 
137
135
  sign_in @user
138
- expect { delete :destroy, :id => contract.id, :use_route => :fine_print }
139
- .to raise_error(ActionController::RoutingError)
136
+ delete :destroy, :id => contract.id, :use_route => :fine_print
137
+ expect(response.status).to eq 403
140
138
  expect(Contract.find(contract.id)).to eq contract
141
139
  end
142
140
 
@@ -149,14 +147,14 @@ module FinePrint
149
147
 
150
148
  it "won't publish unless authorized" do
151
149
  expect(contract.is_published?).to eq false
152
- expect { put :publish, :id => contract.id, :use_route => :fine_print }
153
- .to raise_error(ActionController::RoutingError)
150
+ put :publish, :id => contract.id, :use_route => :fine_print
151
+ expect(response.status).to eq 403
154
152
  contract.reload
155
153
  expect(contract.is_published?).to eq false
156
154
 
157
155
  sign_in @user
158
- expect { put :publish, :id => contract.id, :use_route => :fine_print }
159
- .to raise_error(ActionController::RoutingError)
156
+ put :publish, :id => contract.id, :use_route => :fine_print
157
+ expect(response.status).to eq 403
160
158
  contract.reload
161
159
  expect(contract.is_published?).to eq false
162
160
  end
@@ -174,14 +172,14 @@ module FinePrint
174
172
  it "won't unpublish unless authorized" do
175
173
  contract.publish
176
174
  expect(contract.is_published?).to eq true
177
- expect { put :unpublish, :id => contract.id, :use_route => :fine_print }
178
- .to raise_error(ActionController::RoutingError)
175
+ put :unpublish, :id => contract.id, :use_route => :fine_print
176
+ expect(response.status).to eq 403
179
177
  contract.reload
180
178
  expect(contract.is_published?).to eq true
181
179
 
182
180
  sign_in @user
183
- expect { put :unpublish, :id => contract.id, :use_route => :fine_print }
184
- .to raise_error(ActionController::RoutingError)
181
+ put :unpublish, :id => contract.id, :use_route => :fine_print
182
+ expect(response.status).to eq 403
185
183
  contract.reload
186
184
  expect(contract.is_published?).to eq true
187
185
  end
@@ -201,13 +199,13 @@ module FinePrint
201
199
  contract.publish
202
200
  expect(contract.is_published?).to eq true
203
201
 
204
- expect { put :new_version, :id => contract.id, :use_route => :fine_print }
205
- .to raise_error(ActionController::RoutingError)
202
+ post :new_version, :id => contract.id, :use_route => :fine_print
203
+ expect(response.status).to eq 403
206
204
  expect(assigns(:contract)).to be_nil
207
205
 
208
206
  sign_in @user
209
- expect { put :new_version, :id => contract.id, :use_route => :fine_print }
210
- .to raise_error(ActionController::RoutingError)
207
+ post :new_version, :id => contract.id, :use_route => :fine_print
208
+ expect(response.status).to eq 403
211
209
  expect(assigns(:contract)).to be_nil
212
210
  end
213
211
 
@@ -216,7 +214,7 @@ module FinePrint
216
214
  expect(contract.is_published?).to eq true
217
215
 
218
216
  sign_in @admin
219
- put :new_version, :id => contract.id, :use_route => :fine_print
217
+ post :new_version, :id => contract.id, :use_route => :fine_print
220
218
  expect(response.status).to eq 200
221
219
  expect(assigns(:contract)).not_to be_nil
222
220
  end
@@ -9,12 +9,12 @@ module FinePrint
9
9
  end
10
10
 
11
11
  it "won't get index unless authorized" do
12
- expect { get :index, :use_route => :fine_print }
13
- .to raise_error(ActionController::RoutingError)
12
+ get :index, :use_route => :fine_print
13
+ expect(response.status).to eq 403
14
14
 
15
15
  sign_in @user
16
- expect { get :index, :use_route => :fine_print }
17
- .to raise_error(ActionController::RoutingError)
16
+ get :index, :use_route => :fine_print
17
+ expect(response.status).to eq 403
18
18
  end
19
19
 
20
20
  it 'must get index if authorized' do
@@ -11,14 +11,12 @@ module FinePrint
11
11
  let!(:signature) { FactoryGirl.create(:fine_print_signature) }
12
12
 
13
13
  it "won't get index unless authorized" do
14
- expect { get :index, :contract_id => signature.contract.id,
15
- :use_route => :fine_print }
16
- .to raise_error(ActionController::RoutingError)
14
+ get :index, :contract_id => signature.contract.id, :use_route => :fine_print
15
+ expect(response.status).to eq 403
17
16
 
18
17
  sign_in @user
19
- expect { get :index, :contract_id => signature.contract.id,
20
- :use_route => :fine_print }
21
- .to raise_error(ActionController::RoutingError)
18
+ get :index, :contract_id => signature.contract.id, :use_route => :fine_print
19
+ expect(response.status).to eq 403
22
20
  end
23
21
 
24
22
  it 'must get index if authorized' do
@@ -31,7 +29,7 @@ module FinePrint
31
29
  it "won't get new unless signed in" do
32
30
  get :new, :contract_id => signature.contract.id,
33
31
  :use_route => :fine_print
34
- expect(response.status).to eq 403
32
+ expect(response.status).to eq 401
35
33
  end
36
34
 
37
35
  it 'must get new if signed in' do
@@ -44,7 +42,7 @@ module FinePrint
44
42
  it "won't create unless signed in" do
45
43
  post :create, :contract_id => signature.contract.id,
46
44
  :use_route => :fine_print
47
- expect(response.status).to eq 403
45
+ expect(response.status).to eq 401
48
46
  end
49
47
 
50
48
  it 'must create if signed in' do
@@ -55,13 +53,13 @@ module FinePrint
55
53
  end
56
54
 
57
55
  it "won't destroy unless authorized" do
58
- expect { delete :destroy, :id => signature.id, :use_route => :fine_print }
59
- .to raise_error(ActionController::RoutingError)
56
+ delete :destroy, :id => signature.id, :use_route => :fine_print
57
+ expect(response.status).to eq 403
60
58
  expect(Signature.find(signature.id)).to eq signature
61
59
 
62
60
  sign_in @user
63
- expect { delete :destroy, :id => signature.id, :use_route => :fine_print }
64
- .to raise_error(ActionController::RoutingError)
61
+ delete :destroy, :id => signature.id, :use_route => :fine_print
62
+ expect(response.status).to eq 403
65
63
  expect(Signature.find(signature.id)).to eq signature
66
64
  end
67
65
 
@@ -1,5 +1,4 @@
1
1
  # Configuration file for the dummy app
2
2
  FinePrint.configure do |config|
3
- config.can_manage_proc = lambda { |user| user.try(:is_admin) || \
4
- raise(ActionController::RoutingError, 'Not Found') }
3
+ config.can_manage_proc = lambda { |user| user.try(:is_admin) || head(:forbidden) }
5
4
  end
Binary file