consul 0.12.2 → 0.12.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of consul might be problematic. Click here for more details.

Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/consul.gemspec +1 -1
  4. data/lib/consul/version.rb +1 -1
  5. metadata +2 -126
  6. data/spec/rails-2.3/Gemfile +0 -13
  7. data/spec/rails-2.3/Gemfile.lock +0 -65
  8. data/spec/rails-2.3/Rakefile +0 -11
  9. data/spec/rails-2.3/app_root/app +0 -1
  10. data/spec/rails-2.3/app_root/config/boot.rb +0 -128
  11. data/spec/rails-2.3/app_root/config/database.yml +0 -21
  12. data/spec/rails-2.3/app_root/config/environment.rb +0 -14
  13. data/spec/rails-2.3/app_root/config/environments/in_memory.rb +0 -0
  14. data/spec/rails-2.3/app_root/config/environments/mysql.rb +0 -0
  15. data/spec/rails-2.3/app_root/config/environments/postgresql.rb +0 -0
  16. data/spec/rails-2.3/app_root/config/environments/sqlite.rb +0 -0
  17. data/spec/rails-2.3/app_root/config/environments/sqlite3.rb +0 -0
  18. data/spec/rails-2.3/app_root/config/initializers/fix_missing_source_file.rb +0 -1
  19. data/spec/rails-2.3/app_root/config/preinitializer.rb +0 -20
  20. data/spec/rails-2.3/app_root/config/routes.rb +0 -21
  21. data/spec/rails-2.3/app_root/db +0 -1
  22. data/spec/rails-2.3/app_root/log/.gitignore +0 -1
  23. data/spec/rails-2.3/rcov.opts +0 -2
  24. data/spec/rails-2.3/spec.opts +0 -4
  25. data/spec/rails-2.3/spec/spec_helper.rb +0 -36
  26. data/spec/rails-3.0/.rspec +0 -2
  27. data/spec/rails-3.0/Gemfile +0 -11
  28. data/spec/rails-3.0/Gemfile.lock +0 -126
  29. data/spec/rails-3.0/Rakefile +0 -11
  30. data/spec/rails-3.0/app_root/.gitignore +0 -4
  31. data/spec/rails-3.0/app_root/app +0 -1
  32. data/spec/rails-3.0/app_root/config/application.rb +0 -31
  33. data/spec/rails-3.0/app_root/config/boot.rb +0 -13
  34. data/spec/rails-3.0/app_root/config/database.yml +0 -4
  35. data/spec/rails-3.0/app_root/config/environment.rb +0 -5
  36. data/spec/rails-3.0/app_root/config/environments/test.rb +0 -35
  37. data/spec/rails-3.0/app_root/config/initializers/backtrace_silencers.rb +0 -7
  38. data/spec/rails-3.0/app_root/config/initializers/inflections.rb +0 -10
  39. data/spec/rails-3.0/app_root/config/initializers/mime_types.rb +0 -5
  40. data/spec/rails-3.0/app_root/config/initializers/secret_token.rb +0 -7
  41. data/spec/rails-3.0/app_root/config/initializers/session_store.rb +0 -8
  42. data/spec/rails-3.0/app_root/config/routes.rb +0 -3
  43. data/spec/rails-3.0/app_root/db +0 -1
  44. data/spec/rails-3.0/app_root/lib/tasks/.gitkeep +0 -0
  45. data/spec/rails-3.0/app_root/log/.gitkeep +0 -0
  46. data/spec/rails-3.0/app_root/script/rails +0 -6
  47. data/spec/rails-3.0/rcov.opts +0 -2
  48. data/spec/rails-3.0/spec/spec_helper.rb +0 -23
  49. data/spec/rails-3.2/.rspec +0 -2
  50. data/spec/rails-3.2/Gemfile +0 -11
  51. data/spec/rails-3.2/Gemfile.lock +0 -135
  52. data/spec/rails-3.2/Rakefile +0 -11
  53. data/spec/rails-3.2/app_root/.gitignore +0 -4
  54. data/spec/rails-3.2/app_root/app +0 -1
  55. data/spec/rails-3.2/app_root/config/application.rb +0 -31
  56. data/spec/rails-3.2/app_root/config/boot.rb +0 -13
  57. data/spec/rails-3.2/app_root/config/database.yml +0 -4
  58. data/spec/rails-3.2/app_root/config/environment.rb +0 -5
  59. data/spec/rails-3.2/app_root/config/environments/test.rb +0 -35
  60. data/spec/rails-3.2/app_root/config/initializers/backtrace_silencers.rb +0 -7
  61. data/spec/rails-3.2/app_root/config/initializers/inflections.rb +0 -10
  62. data/spec/rails-3.2/app_root/config/initializers/mime_types.rb +0 -5
  63. data/spec/rails-3.2/app_root/config/initializers/secret_token.rb +0 -7
  64. data/spec/rails-3.2/app_root/config/initializers/session_store.rb +0 -8
  65. data/spec/rails-3.2/app_root/config/routes.rb +0 -3
  66. data/spec/rails-3.2/app_root/db +0 -1
  67. data/spec/rails-3.2/app_root/log/.gitignore +0 -1
  68. data/spec/rails-3.2/rcov.opts +0 -2
  69. data/spec/rails-3.2/spec/spec_helper.rb +0 -27
  70. data/spec/rails-4.1/.rspec +0 -2
  71. data/spec/rails-4.1/Gemfile +0 -12
  72. data/spec/rails-4.1/Gemfile.lock +0 -134
  73. data/spec/rails-4.1/Rakefile +0 -12
  74. data/spec/rails-4.1/app_root/.gitignore +0 -16
  75. data/spec/rails-4.1/app_root/app +0 -1
  76. data/spec/rails-4.1/app_root/bin/bundle +0 -3
  77. data/spec/rails-4.1/app_root/bin/rails +0 -8
  78. data/spec/rails-4.1/app_root/bin/rake +0 -8
  79. data/spec/rails-4.1/app_root/bin/spring +0 -18
  80. data/spec/rails-4.1/app_root/config/application.rb +0 -28
  81. data/spec/rails-4.1/app_root/config/boot.rb +0 -4
  82. data/spec/rails-4.1/app_root/config/database.yml +0 -4
  83. data/spec/rails-4.1/app_root/config/environment.rb +0 -5
  84. data/spec/rails-4.1/app_root/config/environments/development.rb +0 -37
  85. data/spec/rails-4.1/app_root/config/environments/production.rb +0 -83
  86. data/spec/rails-4.1/app_root/config/environments/test.rb +0 -39
  87. data/spec/rails-4.1/app_root/config/initializers/backtrace_silencers.rb +0 -7
  88. data/spec/rails-4.1/app_root/config/initializers/cookies_serializer.rb +0 -3
  89. data/spec/rails-4.1/app_root/config/initializers/filter_parameter_logging.rb +0 -4
  90. data/spec/rails-4.1/app_root/config/initializers/inflections.rb +0 -16
  91. data/spec/rails-4.1/app_root/config/initializers/mime_types.rb +0 -4
  92. data/spec/rails-4.1/app_root/config/initializers/session_store.rb +0 -3
  93. data/spec/rails-4.1/app_root/config/initializers/wrap_parameters.rb +0 -14
  94. data/spec/rails-4.1/app_root/config/locales/en.yml +0 -23
  95. data/spec/rails-4.1/app_root/config/routes.rb +0 -3
  96. data/spec/rails-4.1/app_root/config/secrets.yml +0 -22
  97. data/spec/rails-4.1/app_root/db +0 -1
  98. data/spec/rails-4.1/log/test.log +0 -0
  99. data/spec/rails-4.1/rcov.opts +0 -2
  100. data/spec/rails-4.1/spec/spec_helper.rb +0 -30
  101. data/spec/shared/app_root/app/controllers/application_controller.rb +0 -16
  102. data/spec/shared/app_root/app/controllers/cakes_controller.rb +0 -55
  103. data/spec/shared/app_root/app/controllers/client_notes_controller.rb +0 -13
  104. data/spec/shared/app_root/app/controllers/colors_controller.rb +0 -10
  105. data/spec/shared/app_root/app/controllers/dashboards_controller.rb +0 -20
  106. data/spec/shared/app_root/app/controllers/risks_controller.rb +0 -7
  107. data/spec/shared/app_root/app/controllers/songs_controller.rb +0 -14
  108. data/spec/shared/app_root/app/controllers/users_controller.rb +0 -13
  109. data/spec/shared/app_root/app/models/client.rb +0 -9
  110. data/spec/shared/app_root/app/models/deal.rb +0 -3
  111. data/spec/shared/app_root/app/models/deal/item.rb +0 -3
  112. data/spec/shared/app_root/app/models/note.rb +0 -7
  113. data/spec/shared/app_root/app/models/power.rb +0 -133
  114. data/spec/shared/app_root/app/models/song.rb +0 -6
  115. data/spec/shared/app_root/app/models/user.rb +0 -8
  116. data/spec/shared/app_root/db/migrate/001_create_users.rb +0 -13
  117. data/spec/shared/app_root/db/migrate/002_create_clients.rb +0 -13
  118. data/spec/shared/app_root/db/migrate/003_create_notes.rb +0 -13
  119. data/spec/shared/app_root/db/migrate/004_create_songs.rb +0 -14
  120. data/spec/shared/consul/active_record_spec.rb +0 -37
  121. data/spec/shared/consul/controllers/cakes_controller_spec.rb +0 -61
  122. data/spec/shared/consul/controllers/client_notes_controller_spec.rb +0 -25
  123. data/spec/shared/consul/controllers/colors_controller_spec.rb +0 -29
  124. data/spec/shared/consul/controllers/dashboards_controller_spec.rb +0 -26
  125. data/spec/shared/consul/controllers/risks_controller_spec.rb +0 -9
  126. data/spec/shared/consul/controllers/songs_controller_spec.rb +0 -13
  127. data/spec/shared/consul/controllers/users_controller_spec.rb +0 -25
  128. data/spec/shared/consul/power_spec.rb +0 -688
  129. data/spec/shared/consul/util_spec.rb +0 -17
@@ -1,16 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- include Consul::Controller
3
-
4
- require_power_check
5
-
6
- current_power do
7
- Power.new(User.new)
8
- end
9
-
10
- private
11
-
12
- def render_nothing
13
- render :nothing => true
14
- end
15
-
16
- end
@@ -1,55 +0,0 @@
1
- class CakesController < ApplicationController
2
-
3
- power :crud => :cakes, :as => :end_of_association_chain
4
-
5
- def show
6
- notify_spy
7
- render_nothing
8
- end
9
-
10
- def index
11
- notify_spy
12
- render_nothing
13
- end
14
-
15
- def new
16
- notify_spy
17
- render_nothing
18
- end
19
-
20
- def create
21
- notify_spy
22
- render_nothing
23
- end
24
-
25
- def edit
26
- notify_spy
27
- render_nothing
28
- end
29
-
30
- def update
31
- notify_spy
32
- render_nothing
33
- end
34
-
35
- def destroy
36
- notify_spy
37
- render_nothing
38
- end
39
-
40
- def custom_action
41
- notify_spy
42
- render_nothing
43
- end
44
-
45
- private
46
-
47
- def notify_spy
48
- observe_end_of_association_chain(end_of_association_chain)
49
- end
50
-
51
- def observe_end_of_association_chain(scope)
52
- # spy for spec
53
- end
54
-
55
- end
@@ -1,13 +0,0 @@
1
- class ClientNotesController < ApplicationController
2
-
3
- power :clients, :as => :client_scope
4
-
5
- power :client_notes, :context => :client, :as => :note_scope
6
-
7
- private
8
-
9
- def client
10
- @client ||= client_scope.find(params[:client_id])
11
- end
12
-
13
- end
@@ -1,10 +0,0 @@
1
- class ColorsController < ApplicationController
2
-
3
- power :red, :as => :red_scope
4
- power :blue, :as => :blue_scope
5
-
6
- def show
7
- render_nothing
8
- end
9
-
10
- end
@@ -1,20 +0,0 @@
1
- class DashboardsController < ApplicationController
2
-
3
- power :always_true
4
-
5
- def show
6
- observe(current_power)
7
- render_nothing
8
- end
9
-
10
- def error
11
- raise 'error during action'
12
- end
13
-
14
- private
15
-
16
- def observe(object)
17
- # test spy
18
- end
19
-
20
- end
@@ -1,7 +0,0 @@
1
- class RisksController < ActionController::Base
2
- include Consul::Controller
3
-
4
- def show
5
- end
6
-
7
- end
@@ -1,14 +0,0 @@
1
- class SongsController < ApplicationController
2
-
3
- # power check is missing, but we're skipping it for a single action'
4
- skip_power_check :only => :show
5
-
6
- def show
7
- render_nothing
8
- end
9
-
10
- def update
11
- render_nothing
12
- end
13
-
14
- end
@@ -1,13 +0,0 @@
1
- class UsersController < ApplicationController
2
-
3
- power :always_false, :map => { :show => :always_true }
4
-
5
- def show
6
- render_nothing
7
- end
8
-
9
- def update
10
- render_nothing
11
- end
12
-
13
- end
@@ -1,9 +0,0 @@
1
- class Client < ActiveRecord::Base
2
-
3
- has_many :notes
4
-
5
- def self.active
6
- scoped(:conditions => ["deleted = ? OR deleted IS NULL", false])
7
- end
8
-
9
- end
@@ -1,3 +0,0 @@
1
- class Deal
2
-
3
- end
@@ -1,3 +0,0 @@
1
- class Deal::Item
2
-
3
- end
@@ -1,7 +0,0 @@
1
- class Note < ActiveRecord::Base
2
-
3
- belongs_to :client
4
-
5
- validates_presence_of :client_id
6
-
7
- end
@@ -1,133 +0,0 @@
1
- class Power
2
- include Consul::Power
3
-
4
- def initialize(*args)
5
- @options = args.extract_options!
6
- @user = args.first
7
- end
8
-
9
- power :clients do
10
- Client.active unless guest?
11
- end
12
-
13
- power :all_clients do
14
- Client
15
- end
16
-
17
- power :fast_clients do
18
- Client.active
19
- end
20
-
21
- power :fast_client? do |client|
22
- !client.deleted?
23
- end
24
-
25
- power :client_notes do |client|
26
- client.notes
27
- end
28
-
29
- power :fast_client_notes do |client|
30
- client.notes
31
- end
32
-
33
- power :fast_client_note? do |client, note|
34
- note.client_id == client.id
35
- end
36
-
37
- power :fast_client_note_without_collection? do |client, note|
38
- note.client_id == client.id
39
- end
40
-
41
- power :notes do
42
- Note.scoped(:joins => :client)
43
- end
44
-
45
- power :always_true do
46
- true
47
- end
48
-
49
- power :always_false do
50
- false
51
- end
52
-
53
- power :always_nil do
54
- nil
55
- end
56
-
57
- power :cakes do
58
- :cakes
59
- end
60
-
61
- power :updatable_cakes do
62
- :updatable_cakes
63
- end
64
-
65
- power :creatable_cakes do
66
- :creatable_cakes
67
- end
68
-
69
- power :destroyable_cakes do
70
- :destroyable_cakes
71
- end
72
-
73
- def assignable_user_roles
74
- %w[guest admin]
75
- end
76
-
77
- power :key_figures do
78
- %w[amount working_costs] unless guest?
79
- end
80
-
81
- power :api_key do
82
- 'secret-api-key' unless guest?
83
- end
84
-
85
- power :shorthand1, :shorthand2, :shorthand3 do
86
- 'shorthand'
87
- end
88
-
89
- power :songs do
90
- Song
91
- end
92
-
93
- power :recent_songs do
94
- Song.recent
95
- end
96
-
97
- power :deals do
98
- 'deals power' unless guest?
99
- end
100
-
101
- power :updatable_deals do
102
- 'updatable_deals power' unless guest?
103
- end
104
-
105
- power :deal_items do
106
- 'deal_items power'
107
- end
108
-
109
- power :red do
110
- 'red' if @options[:red]
111
- end
112
-
113
- power :blue do
114
- 'blue' if @options[:blue]
115
- end
116
-
117
- private
118
-
119
- attr_accessor :user
120
-
121
- def role
122
- user.role
123
- end
124
-
125
- def admin?
126
- user.role == 'admin'
127
- end
128
-
129
- def guest?
130
- user.role == 'guest'
131
- end
132
-
133
- end
@@ -1,6 +0,0 @@
1
- class Song < ActiveRecord::Base
2
-
3
- Consul::Util.define_default_scope self, :conditions => { :trashed => true }
4
- Consul::Util.define_scope self, :recent, lambda { { :conditions => ['created_at > ?', 1.week.ago] } }
5
-
6
- end
@@ -1,8 +0,0 @@
1
- class User < ActiveRecord::Base
2
-
3
- def power
4
- @power ||= Power.new(self)
5
- end
6
-
7
- end
8
-
@@ -1,13 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
-
3
- def self.up
4
- create_table :users do |t|
5
- t.string :role
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :users
11
- end
12
-
13
- end
@@ -1,13 +0,0 @@
1
- class CreateClients < ActiveRecord::Migration
2
-
3
- def self.up
4
- create_table :clients do |t|
5
- t.boolean :deleted
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :clients
11
- end
12
-
13
- end
@@ -1,13 +0,0 @@
1
- class CreateNotes < ActiveRecord::Migration
2
-
3
- def self.up
4
- create_table :notes do |t|
5
- t.integer :client_id
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :notes
11
- end
12
-
13
- end
@@ -1,14 +0,0 @@
1
- class CreateSongs < ActiveRecord::Migration
2
-
3
- def self.up
4
- create_table :songs do |t|
5
- t.boolean :trashed
6
- t.timestamps
7
- end
8
- end
9
-
10
- def self.down
11
- drop_table :songs
12
- end
13
-
14
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Consul::ActiveRecord do
4
-
5
- describe '.authorize_values_for' do
6
-
7
- it 'should be a shortcut for .assignable_values_for :attribute, :through => lambda { ::Power.current }' do
8
- klass = Note.disposable_copy
9
- klass.should_receive(:assignable_values_for).with(:attribute, :option => 'option', :through => kind_of(Proc))
10
- klass.class_eval do
11
- authorize_values_for :attribute, :option => 'option'
12
- end
13
- end
14
-
15
- it 'should not generate a getter and setter for a @power field (change from previous versions)' do
16
- klass = Note.disposable_copy do
17
- authorize_values_for :attribute
18
- end
19
- note = klass.new
20
- note.should_not respond_to(:power)
21
- note.should_not respond_to(:power=)
22
- end
23
-
24
- it 'should obtain assignable values from Power.current' do
25
- Power.current = Power.new
26
- klass = User.disposable_copy do
27
- authorize_values_for :role
28
- end
29
- user = klass.new
30
- user.assignable_roles.should =~ %w[guest admin]
31
- user.should allow_value('guest').for(:role)
32
- user.should_not allow_value('invalid-value').for(:role)
33
- end
34
-
35
- end
36
-
37
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CakesController, :type => :controller do
4
-
5
- describe '#show' do
6
- it 'should get the power :cakes' do
7
- controller.should_receive(:observe_end_of_association_chain).with(:cakes)
8
- get :show, :id => 'id'
9
- end
10
- end
11
-
12
- describe '#index' do
13
- it 'should get the power :cakes' do
14
- controller.should_receive(:observe_end_of_association_chain).with(:cakes)
15
- get :index
16
- end
17
- end
18
-
19
- describe '#new' do
20
- it 'should get the power :creatable_cakes' do
21
- controller.should_receive(:observe_end_of_association_chain).with(:creatable_cakes)
22
- get :new
23
- end
24
- end
25
-
26
- describe '#creatable' do
27
- it 'should get the power :creatable_cakes' do
28
- controller.should_receive(:observe_end_of_association_chain).with(:creatable_cakes)
29
- post :create
30
- end
31
- end
32
-
33
- describe '#edit' do
34
- it 'should get the power :updatable_cakes' do
35
- controller.should_receive(:observe_end_of_association_chain).with(:updatable_cakes)
36
- get :edit, :id => 'id'
37
- end
38
- end
39
-
40
- describe '#update' do
41
- it 'should get the power :updatable_cakes' do
42
- controller.should_receive(:observe_end_of_association_chain).with(:updatable_cakes)
43
- put :update, :id => 'id'
44
- end
45
- end
46
-
47
- describe '#destroy' do
48
- it 'should get the power :destroyable_cakes' do
49
- controller.should_receive(:observe_end_of_association_chain).with(:destroyable_cakes)
50
- delete :destroy, :id => '1'
51
- end
52
- end
53
-
54
- describe '#custom_action' do
55
- it 'should get the power :cakes' do
56
- controller.should_receive(:observe_end_of_association_chain).with(:cakes)
57
- get :custom_action, :id => '1'
58
- end
59
- end
60
-
61
- end