consul 0.11.2 → 0.12.0
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.
- checksums.yaml +15 -0
- data/.travis.yml +1 -0
- data/README.md +6 -4
- data/Rakefile +15 -6
- data/consul.gemspec +1 -1
- data/lib/consul/util.rb +20 -4
- data/lib/consul/version.rb +1 -1
- data/spec/rails-2.3/Gemfile.lock +3 -3
- data/spec/rails-3.0/Gemfile.lock +3 -3
- data/spec/rails-3.2/Gemfile.lock +3 -3
- data/spec/rails-4.1/.rspec +2 -0
- data/spec/rails-4.1/Gemfile +12 -0
- data/spec/rails-4.1/Gemfile.lock +134 -0
- data/spec/rails-4.1/Rakefile +12 -0
- data/spec/rails-4.1/app_root/.gitignore +16 -0
- data/spec/rails-4.1/app_root/bin/bundle +3 -0
- data/spec/rails-4.1/app_root/bin/rails +8 -0
- data/spec/rails-4.1/app_root/bin/rake +8 -0
- data/spec/rails-4.1/app_root/bin/spring +18 -0
- data/spec/rails-4.1/app_root/config/application.rb +28 -0
- data/spec/rails-4.1/app_root/config/boot.rb +4 -0
- data/spec/rails-4.1/app_root/config/database.yml +4 -0
- data/spec/rails-4.1/app_root/config/environment.rb +5 -0
- data/spec/rails-4.1/app_root/config/environments/development.rb +37 -0
- data/spec/rails-4.1/app_root/config/environments/production.rb +83 -0
- data/spec/rails-4.1/app_root/config/environments/test.rb +39 -0
- data/spec/rails-4.1/app_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails-4.1/app_root/config/initializers/cookies_serializer.rb +3 -0
- data/spec/rails-4.1/app_root/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails-4.1/app_root/config/initializers/inflections.rb +16 -0
- data/spec/rails-4.1/app_root/config/initializers/mime_types.rb +4 -0
- data/spec/rails-4.1/app_root/config/initializers/session_store.rb +3 -0
- data/spec/rails-4.1/app_root/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails-4.1/app_root/config/locales/en.yml +23 -0
- data/spec/rails-4.1/app_root/config/routes.rb +3 -0
- data/spec/rails-4.1/app_root/config/secrets.yml +22 -0
- data/spec/rails-4.1/log/test.log +0 -0
- data/spec/rails-4.1/rcov.opts +2 -0
- data/spec/rails-4.1/spec/spec_helper.rb +30 -0
- data/spec/shared/app_root/app/models/song.rb +2 -3
- data/spec/shared/consul/power_spec.rb +34 -34
- metadata +204 -81
@@ -0,0 +1,37 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Raise an error on page load if there are pending migrations.
|
23
|
+
config.active_record.migration_error = :page_load
|
24
|
+
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
29
|
+
|
30
|
+
# Adds additional error checking when serving assets at runtime.
|
31
|
+
# Checks for improperly declared sprockets dependencies.
|
32
|
+
# Raises helpful error messages.
|
33
|
+
config.assets.raise_runtime_errors = true
|
34
|
+
|
35
|
+
# Raises error for missing translations
|
36
|
+
# config.action_view.raise_on_missing_translations = true
|
37
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
21
|
+
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
config.serve_static_assets = false
|
24
|
+
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
28
|
+
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
+
config.assets.compile = false
|
31
|
+
|
32
|
+
# Generate digests for assets URLs.
|
33
|
+
config.assets.digest = true
|
34
|
+
|
35
|
+
# Version of your assets, change this if you want to expire all your assets.
|
36
|
+
config.assets.version = '1.0'
|
37
|
+
|
38
|
+
# Specifies the header that your server uses for sending files.
|
39
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
40
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
41
|
+
|
42
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
43
|
+
# config.force_ssl = true
|
44
|
+
|
45
|
+
# Set to :debug to see everything in the log.
|
46
|
+
config.log_level = :info
|
47
|
+
|
48
|
+
# Prepend all log lines with the following tags.
|
49
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
50
|
+
|
51
|
+
# Use a different logger for distributed setups.
|
52
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
53
|
+
|
54
|
+
# Use a different cache store in production.
|
55
|
+
# config.cache_store = :mem_cache_store
|
56
|
+
|
57
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
58
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
59
|
+
|
60
|
+
# Precompile additional assets.
|
61
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
62
|
+
# config.assets.precompile += %w( search.js )
|
63
|
+
|
64
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
66
|
+
# config.action_mailer.raise_delivery_errors = false
|
67
|
+
|
68
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
69
|
+
# the I18n.default_locale when a translation cannot be found).
|
70
|
+
config.i18n.fallbacks = true
|
71
|
+
|
72
|
+
# Send deprecation notices to registered listeners.
|
73
|
+
config.active_support.deprecation = :notify
|
74
|
+
|
75
|
+
# Disable automatic flushing of the log to improve performance.
|
76
|
+
# config.autoflush_log = false
|
77
|
+
|
78
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
79
|
+
config.log_formatter = ::Logger::Formatter.new
|
80
|
+
|
81
|
+
# Do not dump schema after migrations.
|
82
|
+
config.active_record.dump_schema_after_migration = false
|
83
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_assets = true
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
|
+
|
19
|
+
# Show full error reports and disable caching.
|
20
|
+
config.consider_all_requests_local = true
|
21
|
+
config.action_controller.perform_caching = false
|
22
|
+
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
24
|
+
config.action_dispatch.show_exceptions = false
|
25
|
+
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
|
+
|
29
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
+
# The :test delivery method accumulates sent emails in the
|
31
|
+
# ActionMailer::Base.deliveries array.
|
32
|
+
config.action_mailer.delivery_method = :test
|
33
|
+
|
34
|
+
# Print deprecation notices to the stderr.
|
35
|
+
config.active_support.deprecation = :stderr
|
36
|
+
|
37
|
+
# Raises error for missing translations
|
38
|
+
# config.action_view.raise_on_missing_translations = true
|
39
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 7aa3418aec81500e8e336d984b9d438f602911ae48df0725543b9c72699a9fa84ce099b327d7db2b10f2655963f19139c9c4c86304b9342ccb9c7e389fc65b6e
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 9eb558edf0b5fda539c566df1e3a5b699e7e16267167c797ce838d120a0d52c7c5672bada24457f0ed7b59786e360e2c27e9b9e021cbe98358dc72382cfcd50f
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$: << File.join(File.dirname(__FILE__), "/../../lib" )
|
2
|
+
|
3
|
+
ENV['RAILS_ENV'] ||= 'test'
|
4
|
+
ENV['RAILS_ROOT'] = 'app_root'
|
5
|
+
|
6
|
+
FileUtils.rm(Dir.glob("app_root/db/*.db"), :force => true)
|
7
|
+
|
8
|
+
# Load the Rails environment and testing framework
|
9
|
+
require "#{File.dirname(__FILE__)}/../app_root/config/environment"
|
10
|
+
require 'rspec/rails'
|
11
|
+
|
12
|
+
# DatabaseCleaner.strategy = :truncation
|
13
|
+
|
14
|
+
require 'rspec_candy/helpers'
|
15
|
+
|
16
|
+
# Run the migrations
|
17
|
+
print "\033[30m" # dark gray text
|
18
|
+
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
|
19
|
+
print "\033[0m"
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.use_transactional_fixtures = true
|
23
|
+
config.use_instantiated_fixtures = false
|
24
|
+
config.expect_with :rspec do |c|
|
25
|
+
c.syntax = [:should, :expect]
|
26
|
+
end
|
27
|
+
config.mock_with :rspec do |c|
|
28
|
+
c.syntax = [:should, :expect]
|
29
|
+
end
|
30
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class Song < ActiveRecord::Base
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Consul::Util.define_scope(self, :recent, :conditions => ['created_at > ?', 1.week.ago])
|
3
|
+
Consul::Util.define_default_scope self, :conditions => { :trashed => true }
|
4
|
+
Consul::Util.define_scope self, :recent, lambda { { :conditions => ['created_at > ?', 1.week.ago] } }
|
6
5
|
|
7
6
|
end
|
@@ -32,7 +32,7 @@ describe Consul::Power do
|
|
32
32
|
it 'should return false' do
|
33
33
|
@user.role = 'guest'
|
34
34
|
@user.power.clients.should be_nil
|
35
|
-
@user.power.clients?.should
|
35
|
+
@user.power.clients?.should == false
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -43,7 +43,7 @@ describe Consul::Power do
|
|
43
43
|
client = Client.create!
|
44
44
|
@user.role = 'guest'
|
45
45
|
@user.power.clients.should be_nil
|
46
|
-
@user.power.client?(client).should
|
46
|
+
@user.power.client?(client).should == false
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
@@ -92,14 +92,14 @@ describe Consul::Power do
|
|
92
92
|
context 'when no record is given' do
|
93
93
|
|
94
94
|
it 'should return true if the power returns a scope (which might or might not match records)' do
|
95
|
-
@user.power.clients?.should
|
95
|
+
@user.power.clients?.should == true
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should not trigger a query if the power returns a has many association' do
|
99
99
|
Note.count.should > 0 # show that we have records in the database
|
100
100
|
@client1.reload
|
101
101
|
@user.power.client_notes?(@client1)
|
102
|
-
@client1.notes.loaded?.should
|
102
|
+
@client1.notes.loaded?.should == false
|
103
103
|
end
|
104
104
|
|
105
105
|
end
|
@@ -107,11 +107,11 @@ describe Consul::Power do
|
|
107
107
|
context 'with a given record' do
|
108
108
|
|
109
109
|
it 'should return true if the record belongs to the scope' do
|
110
|
-
@user.power.client?(@client1).should
|
110
|
+
@user.power.client?(@client1).should == true
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'should return false if the record does not belong to the scope' do
|
114
|
-
@user.power.client?(@deleted_client).should
|
114
|
+
@user.power.client?(@deleted_client).should == false
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'should only trigger a single query for multiple checks on the same scope' do
|
@@ -141,8 +141,8 @@ describe Consul::Power do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should work with powers that have arguments' do
|
144
|
-
@user.power.client_note?(@client1, @client1_note1).should
|
145
|
-
@user.power.client_note?(@client1, @client2_note1).should
|
144
|
+
@user.power.client_note?(@client1, @client1_note1).should == true
|
145
|
+
@user.power.client_note?(@client1, @client2_note1).should == false
|
146
146
|
end
|
147
147
|
|
148
148
|
context 'optimization through additional definition of a Ruby method' do
|
@@ -150,13 +150,13 @@ describe Consul::Power do
|
|
150
150
|
it 'should not affect collection access' do
|
151
151
|
@user.power.fast_clients.to_a.should =~ [@client1, @client2]
|
152
152
|
@user.power.fast_client_ids.to_a.should =~ [@client1.id, @client2.id]
|
153
|
-
@user.power.fast_clients?.should
|
153
|
+
@user.power.fast_clients?.should == true
|
154
154
|
end
|
155
155
|
|
156
156
|
it 'should no longer access the database when checking inclusion of a single record' do
|
157
157
|
@user.power.should_not_receive(:database_touched)
|
158
|
-
@user.power.fast_client?(@client1).should
|
159
|
-
@user.power.fast_client?(@deleted_client).should
|
158
|
+
@user.power.fast_client?(@client1).should == true
|
159
|
+
@user.power.fast_client?(@deleted_client).should == false
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'is used by and bang methods' do
|
@@ -167,16 +167,16 @@ describe Consul::Power do
|
|
167
167
|
|
168
168
|
it 'works with parametrized powers' do
|
169
169
|
@user.power.should_not_receive(:database_touched)
|
170
|
-
@user.power.fast_client_note?(@client1, @client1_note1).should
|
171
|
-
@user.power.fast_client_note?(@client1, @client2_note1).should
|
170
|
+
@user.power.fast_client_note?(@client1, @client1_note1).should == true
|
171
|
+
@user.power.fast_client_note?(@client1, @client2_note1).should == false
|
172
172
|
expect { @user.power.fast_client_note!(@client1, @client1_note1) }.to_not raise_error
|
173
173
|
expect { @user.power.fast_client_note!(@client1, @client2_note1) }.to raise_error(Consul::Powerless)
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'works when only the optimized power is defined, without a collection power' do
|
177
177
|
@user.power.should_not_receive(:database_touched)
|
178
|
-
@user.power.fast_client_note_without_collection?(@client1, @client1_note1).should
|
179
|
-
@user.power.fast_client_note_without_collection?(@client1, @client2_note1).should
|
178
|
+
@user.power.fast_client_note_without_collection?(@client1, @client1_note1).should == true
|
179
|
+
@user.power.fast_client_note_without_collection?(@client1, @client2_note1).should == false
|
180
180
|
end
|
181
181
|
|
182
182
|
end
|
@@ -256,13 +256,13 @@ describe Consul::Power do
|
|
256
256
|
context 'when no record is given' do
|
257
257
|
|
258
258
|
it 'should return true if the returns an enumerable (which might or might not be empty)' do
|
259
|
-
@user.power.key_figures?.should
|
259
|
+
@user.power.key_figures?.should == true
|
260
260
|
end
|
261
261
|
|
262
262
|
it 'should return false if the power returns nil' do
|
263
263
|
@user.role = 'guest'
|
264
264
|
@user.power.key_figures.should be_nil
|
265
|
-
@user.power.key_figures?.should
|
265
|
+
@user.power.key_figures?.should == false
|
266
266
|
end
|
267
267
|
|
268
268
|
end
|
@@ -270,11 +270,11 @@ describe Consul::Power do
|
|
270
270
|
context 'with a given record' do
|
271
271
|
|
272
272
|
it 'should return true if the power contains the given record' do
|
273
|
-
@user.power.key_figure?('amount').should
|
273
|
+
@user.power.key_figure?('amount').should == true
|
274
274
|
end
|
275
275
|
|
276
276
|
it 'should return false if the power does not contain the given record' do
|
277
|
-
@user.power.key_figure?('xyz').should
|
277
|
+
@user.power.key_figure?('xyz').should == false
|
278
278
|
end
|
279
279
|
|
280
280
|
end
|
@@ -324,15 +324,15 @@ describe Consul::Power do
|
|
324
324
|
context 'when no record is given' do
|
325
325
|
|
326
326
|
it 'should return true when the queried power returns true' do
|
327
|
-
@user.power.always_true?.should
|
327
|
+
@user.power.always_true?.should == true
|
328
328
|
end
|
329
329
|
|
330
330
|
it 'should return false when the queried power returns false' do
|
331
|
-
@user.power.always_false?.should
|
331
|
+
@user.power.always_false?.should == false
|
332
332
|
end
|
333
333
|
|
334
334
|
it 'should return false when the queried power returns nil' do
|
335
|
-
@user.power.always_nil?.should
|
335
|
+
@user.power.always_nil?.should == false
|
336
336
|
end
|
337
337
|
|
338
338
|
end
|
@@ -389,13 +389,13 @@ describe Consul::Power do
|
|
389
389
|
context 'when no record is given' do
|
390
390
|
|
391
391
|
it 'should return true if the power is not nil' do
|
392
|
-
@user.power.api_key?.should
|
392
|
+
@user.power.api_key?.should == true
|
393
393
|
end
|
394
394
|
|
395
395
|
it 'should return false if the power is nil' do
|
396
396
|
@user.role = 'guest'
|
397
397
|
@user.power.api_key.should be_nil
|
398
|
-
@user.power.api_key?.should
|
398
|
+
@user.power.api_key?.should == false
|
399
399
|
end
|
400
400
|
|
401
401
|
end
|
@@ -570,9 +570,9 @@ describe Consul::Power do
|
|
570
570
|
|
571
571
|
it 'should return if the given model corresponds to a non-nil power' do
|
572
572
|
@user.role = 'guest'
|
573
|
-
@user.power.include_model?(Client).should
|
573
|
+
@user.power.include_model?(Client).should == false
|
574
574
|
@user.role = 'admin'
|
575
|
-
@user.power.include_model?(Client).should
|
575
|
+
@user.power.include_model?(Client).should == true
|
576
576
|
end
|
577
577
|
|
578
578
|
end
|
@@ -584,9 +584,9 @@ describe Consul::Power do
|
|
584
584
|
it 'should return whether the given model corresponds to a non-nil power' do
|
585
585
|
Power.with_power(@user.power) do
|
586
586
|
@user.role = 'guest'
|
587
|
-
Power.include_model?(Deal).should
|
587
|
+
Power.include_model?(Deal).should == false
|
588
588
|
@user.role = 'admin'
|
589
|
-
Power.include_model?(Deal).should
|
589
|
+
Power.include_model?(Deal).should == true
|
590
590
|
end
|
591
591
|
end
|
592
592
|
end
|
@@ -594,7 +594,7 @@ describe Consul::Power do
|
|
594
594
|
context 'when Power.current is nil' do
|
595
595
|
|
596
596
|
it 'should return true' do
|
597
|
-
Power.include_model?(Deal).should
|
597
|
+
Power.include_model?(Deal).should == true
|
598
598
|
end
|
599
599
|
|
600
600
|
end
|
@@ -644,8 +644,8 @@ describe Consul::Power do
|
|
644
644
|
describe '#include_record?' do
|
645
645
|
|
646
646
|
it 'should return if the given record is included in the power corresponding to the class of the given record' do
|
647
|
-
@user.power.include_record?(@deleted_client).should
|
648
|
-
@user.power.include_record?(@client1).should
|
647
|
+
@user.power.include_record?(@deleted_client).should == false
|
648
|
+
@user.power.include_record?(@client1).should == true
|
649
649
|
end
|
650
650
|
|
651
651
|
end
|
@@ -656,8 +656,8 @@ describe Consul::Power do
|
|
656
656
|
|
657
657
|
it 'should return whether the given record is included in the the power corresponding to the class of the given record' do
|
658
658
|
Power.with_power(@user.power) do
|
659
|
-
Power.include_record?(@deleted_client).should
|
660
|
-
Power.include_record?(@client1).should
|
659
|
+
Power.include_record?(@deleted_client).should == false
|
660
|
+
Power.include_record?(@client1).should == true
|
661
661
|
end
|
662
662
|
end
|
663
663
|
end
|
@@ -665,7 +665,7 @@ describe Consul::Power do
|
|
665
665
|
context 'when Power.current is nil' do
|
666
666
|
|
667
667
|
it 'should return true' do
|
668
|
-
Power.include_record?(Deal.new).should
|
668
|
+
Power.include_record?(Deal.new).should == true
|
669
669
|
end
|
670
670
|
|
671
671
|
end
|