fine_print 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -2
  3. data/Rakefile +0 -1
  4. data/app/assets/javascripts/fine_print/application.js +0 -1
  5. data/app/assets/stylesheets/fine_print/application.css +0 -1
  6. data/app/controllers/fine_print/application_controller.rb +9 -4
  7. data/app/controllers/fine_print/contracts_controller.rb +16 -12
  8. data/app/controllers/fine_print/home_controller.rb +5 -0
  9. data/app/controllers/fine_print/signatures_controller.rb +44 -2
  10. data/app/models/fine_print/contract.rb +17 -45
  11. data/app/models/fine_print/signature.rb +4 -3
  12. data/app/views/fine_print/contracts/_show.html.erb +11 -0
  13. data/app/views/fine_print/contracts/edit.html.erb +1 -1
  14. data/app/views/fine_print/contracts/index.html.erb +12 -14
  15. data/app/views/fine_print/contracts/new_version.html.erb +1 -1
  16. data/app/views/fine_print/contracts/show.html.erb +18 -29
  17. data/app/views/fine_print/signatures/_form.html.erb +21 -0
  18. data/app/views/fine_print/signatures/index.html.erb +3 -7
  19. data/app/views/fine_print/signatures/new.html.erb +13 -0
  20. data/config/initializers/fine_print.rb +36 -33
  21. data/config/routes.rb +5 -5
  22. data/db/migrate/0_install_fine_print.rb +2 -3
  23. data/lib/fine_print/controller_includes.rb +41 -67
  24. data/lib/fine_print/engine.rb +3 -0
  25. data/lib/fine_print/version.rb +1 -1
  26. data/lib/fine_print.rb +48 -57
  27. data/spec/controllers/contracts_controller_spec.rb +98 -98
  28. data/spec/controllers/home_controller_spec.rb +7 -5
  29. data/spec/controllers/signatures_controller_spec.rb +48 -19
  30. data/spec/dummy/app/models/dummy_user.rb +0 -1
  31. data/spec/dummy/config/initializers/fine_print.rb +2 -1
  32. data/spec/dummy/db/development.sqlite3 +0 -0
  33. data/spec/dummy/db/test.sqlite3 +0 -0
  34. data/spec/dummy/log/development.log +31970 -0
  35. data/spec/dummy/log/test.log +71587 -0
  36. data/spec/lib/fine_print/controller_includes_spec.rb +9 -14
  37. data/spec/lib/fine_print_spec.rb +15 -9
  38. data/spec/models/contract_spec.rb +17 -25
  39. data/spec/models/signature_spec.rb +4 -14
  40. data/spec/spec_helper.rb +1 -2
  41. metadata +33 -4
  42. data/app/views/fine_print/home/index.html.erb +0 -16
  43. data/lib/fine_print/security_transgression.rb +0 -3
@@ -1,25 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module FinePrint
4
- describe HomeController do
5
- before do
4
+ describe HomeController, :type => :controller do
5
+ routes { FinePrint::Engine.routes }
6
+
7
+ before(:each) do
6
8
  setup_controller_spec
7
9
  end
8
10
 
9
11
  it "won't get index unless authorized" do
10
12
  expect { get :index, :use_route => :fine_print }
11
- .to raise_error(FinePrint::SecurityTransgression)
13
+ .to raise_error(ActionController::RoutingError)
12
14
 
13
15
  sign_in @user
14
16
  expect { get :index, :use_route => :fine_print }
15
- .to raise_error(FinePrint::SecurityTransgression)
17
+ .to raise_error(ActionController::RoutingError)
16
18
  end
17
19
 
18
20
  it 'must get index if authorized' do
19
21
  sign_in @user
20
22
  @user.is_admin = true
21
23
  get :index, :use_route => :fine_print
22
- assert_response :success
24
+ expect(response).to redirect_to contracts_path
23
25
  end
24
26
  end
25
27
  end
@@ -1,46 +1,75 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module FinePrint
4
- describe SignaturesController do
4
+ describe SignaturesController, :type => :controller do
5
5
  routes { FinePrint::Engine.routes }
6
6
 
7
- before do
7
+ before(:each) do
8
8
  setup_controller_spec
9
- @signature = FactoryGirl.create(:signature)
10
- @signature.reload
11
9
  end
12
10
 
11
+ let!(:signature) { FactoryGirl.create(:signature) }
12
+
13
13
  it "won't get index unless authorized" do
14
- expect { get :index, :use_route => :fine_print }
15
- .to raise_error(FinePrint::SecurityTransgression)
14
+ expect { get :index, :contract_id => signature.contract.id,
15
+ :use_route => :fine_print }
16
+ .to raise_error(ActionController::RoutingError)
16
17
 
17
18
  sign_in @user
18
- expect { get :index, :use_route => :fine_print }
19
- .to raise_error(FinePrint::SecurityTransgression)
19
+ expect { get :index, :contract_id => signature.contract.id,
20
+ :use_route => :fine_print }
21
+ .to raise_error(ActionController::RoutingError)
20
22
  end
21
23
 
22
24
  it 'must get index if authorized' do
23
25
  sign_in @admin
24
- get :index, :use_route => :fine_print
25
- assert_response :success
26
+ get :index, :contract_id => signature.contract.id,
27
+ :use_route => :fine_print
28
+ expect(response.status).to eq 200
29
+ end
30
+
31
+ it "won't get new unless signed in" do
32
+ get :new, :contract_id => signature.contract.id,
33
+ :use_route => :fine_print
34
+ expect(response.status).to eq 401
35
+ end
36
+
37
+ it 'must get new if signed in' do
38
+ sign_in @user
39
+ get :new, :contract_id => signature.contract.id,
40
+ :use_route => :fine_print
41
+ expect(response.status).to eq 200
42
+ end
43
+
44
+ it "won't create unless signed in" do
45
+ post :create, :contract_id => signature.contract.id,
46
+ :use_route => :fine_print
47
+ expect(response.status).to eq 401
48
+ end
49
+
50
+ it 'must create if signed in' do
51
+ sign_in @user
52
+ get :new, :contract_id => signature.contract.id,
53
+ :use_route => :fine_print
54
+ expect(response.status).to eq 200
26
55
  end
27
56
 
28
57
  it "won't destroy unless authorized" do
29
- expect { delete :destroy, :id => @signature.id, :use_route => :fine_print }
30
- .to raise_error(FinePrint::SecurityTransgression)
31
- expect(Signature.find(@signature.id)).to eq @signature
58
+ expect { delete :destroy, :id => signature.id, :use_route => :fine_print }
59
+ .to raise_error(ActionController::RoutingError)
60
+ expect(Signature.find(signature.id)).to eq signature
32
61
 
33
62
  sign_in @user
34
- expect { delete :destroy, :id => @signature.id, :use_route => :fine_print }
35
- .to raise_error(FinePrint::SecurityTransgression)
36
- expect(Signature.find(@signature.id)).to eq @signature
63
+ expect { delete :destroy, :id => signature.id, :use_route => :fine_print }
64
+ .to raise_error(ActionController::RoutingError)
65
+ expect(Signature.find(signature.id)).to eq signature
37
66
  end
38
67
 
39
68
  it 'must destroy if authorized' do
40
69
  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
70
+ delete :destroy, :id => signature.id, :use_route => :fine_print
71
+ expect(response).to redirect_to contract_signatures_path(signature.contract)
72
+ expect(Signature.find_by_id(signature.id)).to be_nil
44
73
  end
45
74
  end
46
75
  end
@@ -1,3 +1,2 @@
1
1
  class DummyUser < ActiveRecord::Base
2
- # attr_accessible :title, :body
3
2
  end
@@ -1,4 +1,5 @@
1
1
  # Configuration file for the dummy app
2
2
  FinePrint.configure do |config|
3
- config.user_admin_proc = lambda { |user| user.is_admin }
3
+ config.can_manage_proc = lambda { |user| user.try(:is_admin) || \
4
+ raise(ActionController::RoutingError, 'Not Found') }
4
5
  end
Binary file
Binary file