rpbk 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rpbk/ext/renderer.rb +26 -0
- data/lib/rpbk/holder.rb +151 -0
- data/lib/rpbk/set.rb +77 -0
- data/lib/rpbk/version.rb +1 -1
- data/test/dummy/.rspec +1 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/admin/controller1.js +2 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/javascripts/controller1.js +2 -0
- data/test/dummy/app/assets/stylesheets/admin/controller1.css +4 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/assets/stylesheets/controller1.css +4 -0
- data/test/dummy/app/controllers/admin/controller1_controller.rb +5 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/controller1_controller.rb +8 -0
- data/test/dummy/app/helpers/admin/controller1_helper.rb +2 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/controller1_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/admin/controller1/action1.html.erb +1 -0
- data/test/dummy/app/views/controller1/action1.html.erb +1 -0
- data/test/dummy/app/views/controller1/action2.html.erb +2 -0
- data/test/dummy/app/views/layouts/_test_partial.html.erb +1 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/web.html.erb +15 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +70 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/spec/controllers/admin/controller1_controller_spec.rb +10 -0
- data/test/dummy/spec/rpbk/set_spec.rb +350 -0
- data/test/dummy/spec/rpbk_spec.rb +25 -0
- data/test/dummy/spec/spec_helper.rb +27 -0
- data/test/dummy/spec/views/admin/controller1/action1.html.erb_spec.rb +47 -0
- data/test/dummy/spec/views/controller1/action1.html.erb_spec.rb +47 -0
- data/test/dummy/spec/views/controller1/action2.html.erb_spec.rb +4 -0
- metadata +55 -1
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Dummy::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
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
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
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Do not compress assets
|
26
|
+
config.assets.compress = false
|
27
|
+
|
28
|
+
# Expands the lines which load the assets
|
29
|
+
config.assets.debug = true
|
30
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Dummy::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
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Defaults to Rails.root.join("public/assets")
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
25
|
+
|
26
|
+
# Specifies the header that your server uses for sending files
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
|
+
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
|
+
# config.force_ssl = true
|
32
|
+
|
33
|
+
# See everything in the log (default is :info)
|
34
|
+
# config.log_level = :debug
|
35
|
+
|
36
|
+
# Use a different logger for distributed setups
|
37
|
+
# config.logger = SyslogLogger.new
|
38
|
+
|
39
|
+
# Use a different cache store in production
|
40
|
+
# config.cache_store = :mem_cache_store
|
41
|
+
|
42
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
43
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
44
|
+
|
45
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
46
|
+
# config.assets.precompile += %w( search.js )
|
47
|
+
|
48
|
+
# Disable delivery errors, bad email addresses will be ignored
|
49
|
+
# config.action_mailer.raise_delivery_errors = false
|
50
|
+
|
51
|
+
# Enable threaded mode
|
52
|
+
# config.threadsafe!
|
53
|
+
|
54
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
55
|
+
# the I18n.default_locale when a translation can not be found)
|
56
|
+
config.i18n.fallbacks = true
|
57
|
+
|
58
|
+
# Send deprecation notices to registered listeners
|
59
|
+
config.active_support.deprecation = :notify
|
60
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Dummy::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
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
33
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
34
|
+
# like if you have constraints or database-specific column types
|
35
|
+
# config.active_record.schema_format = :sql
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr
|
38
|
+
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
41
|
+
config.assets.allow_debugging = true
|
42
|
+
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,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'da582f059a8334a6e51f5f2639a92a2f158b2ec34c5506cf1ce61c1dd0576ea4171bc04ec16b0587cf9c1d7bdc017ee60ff0d89e76a1f2a9b58dee41070c7a02'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -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]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
get "controller2/action1"
|
3
|
+
|
4
|
+
get "controller2/action2"
|
5
|
+
|
6
|
+
get "controller1/action1"
|
7
|
+
|
8
|
+
get "controller1/action2"
|
9
|
+
|
10
|
+
namespace :admin do
|
11
|
+
get "controller1/action1"
|
12
|
+
end
|
13
|
+
|
14
|
+
# The priority is based upon order of creation:
|
15
|
+
# first created -> highest priority.
|
16
|
+
|
17
|
+
# Sample of regular route:
|
18
|
+
# match 'products/:id' => 'catalog#view'
|
19
|
+
# Keep in mind you can assign values other than :controller and :action
|
20
|
+
|
21
|
+
# Sample of named route:
|
22
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
23
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
24
|
+
|
25
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
26
|
+
# resources :products
|
27
|
+
|
28
|
+
# Sample resource route with options:
|
29
|
+
# resources :products do
|
30
|
+
# member do
|
31
|
+
# get 'short'
|
32
|
+
# post 'toggle'
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# collection do
|
36
|
+
# get 'sold'
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
|
40
|
+
# Sample resource route with sub-resources:
|
41
|
+
# resources :products do
|
42
|
+
# resources :comments, :sales
|
43
|
+
# resource :seller
|
44
|
+
# end
|
45
|
+
|
46
|
+
# Sample resource route with more complex sub-resources
|
47
|
+
# resources :products do
|
48
|
+
# resources :comments
|
49
|
+
# resources :sales do
|
50
|
+
# get 'recent', :on => :collection
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
|
54
|
+
# Sample resource route within a namespace:
|
55
|
+
# namespace :admin do
|
56
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
57
|
+
# # (app/controllers/admin/products_controller.rb)
|
58
|
+
# resources :products
|
59
|
+
# end
|
60
|
+
|
61
|
+
# You can have the root of your site routed with "root"
|
62
|
+
# just remember to delete public/index.html.
|
63
|
+
# root :to => 'welcome#index'
|
64
|
+
|
65
|
+
# See how all your routes lay out with "rake routes"
|
66
|
+
|
67
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
68
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
69
|
+
# match ':controller(/:action(/:id(.:format)))'
|
70
|
+
end
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,350 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rpbk::Set do
|
4
|
+
before :each do
|
5
|
+
Rpbk.drop_configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#layout" do
|
9
|
+
it "should set the layout for application" do
|
10
|
+
Rpbk.setup.config do
|
11
|
+
set :key => :variable
|
12
|
+
layout :web
|
13
|
+
end
|
14
|
+
Rpbk.layout.should == :web
|
15
|
+
end
|
16
|
+
it "should set the layout for controller" do
|
17
|
+
Rpbk.setup.config do
|
18
|
+
set :key => :variable
|
19
|
+
layout :application
|
20
|
+
controller :controller1 do
|
21
|
+
layout :web
|
22
|
+
end
|
23
|
+
end
|
24
|
+
Rpbk.layout(:controller1).should == :web
|
25
|
+
end
|
26
|
+
it "should set the layout for action" do
|
27
|
+
Rpbk.setup.config do
|
28
|
+
set :key => :variable
|
29
|
+
layout :application
|
30
|
+
controller :controller1 do
|
31
|
+
layout :application
|
32
|
+
action :action1 do
|
33
|
+
layout :web
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Rpbk.layout(:controller1, :action1).should == :web
|
38
|
+
end
|
39
|
+
it "should extend the layout" do
|
40
|
+
Rpbk.setup.config do
|
41
|
+
group :group1 do
|
42
|
+
layout :group1
|
43
|
+
end
|
44
|
+
group :group2 do
|
45
|
+
layout :group2
|
46
|
+
end
|
47
|
+
layout :main
|
48
|
+
controller :controller1, :extend => :group2 do
|
49
|
+
action :action1, :extend => :group1
|
50
|
+
action :action2, :extend => [:group1, :group2]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
Rpbk.layout(:controller1).should == :group2
|
54
|
+
Rpbk.layout(:controller1, :action1).should == :group1
|
55
|
+
Rpbk.layout(:controller1, :action2).should == :group2
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#set" do
|
60
|
+
it "should add data to attributes" do
|
61
|
+
Rpbk.setup.config do
|
62
|
+
set :key => :variable
|
63
|
+
end
|
64
|
+
Rpbk.find(:key).should equal(Rpbk::Attribute.new(:key, :variable))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#controller" do
|
69
|
+
it "should add data to controllers" do
|
70
|
+
Rpbk.setup.config do
|
71
|
+
controller :controller_name do
|
72
|
+
set :key => :variable
|
73
|
+
end
|
74
|
+
end
|
75
|
+
Rpbk.find(:key).should be_nil
|
76
|
+
Rpbk.find(:key, :controller_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
77
|
+
end
|
78
|
+
it "should be able extend any group" do
|
79
|
+
Rpbk.setup.config do
|
80
|
+
group :group_name do
|
81
|
+
set :key => :variable1, :key2 => :variable2
|
82
|
+
end
|
83
|
+
controller :controller_name, :extend => :group_name do
|
84
|
+
set :key => :variable
|
85
|
+
end
|
86
|
+
end
|
87
|
+
Rpbk.find(:key, :controller_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
88
|
+
Rpbk.find(:key2, :controller_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
89
|
+
end
|
90
|
+
it "should be able extend any controller" do
|
91
|
+
Rpbk.setup.config do
|
92
|
+
controller :controller_name do
|
93
|
+
set :key => :variable1, :key2 => :variable2
|
94
|
+
end
|
95
|
+
controller :controller2_name, :extend => :controller_name do
|
96
|
+
set :key => :variable
|
97
|
+
end
|
98
|
+
end
|
99
|
+
Rpbk.find(:key, :controller2_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
100
|
+
Rpbk.find(:key2, :controller2_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
101
|
+
end
|
102
|
+
it "should be able extend many groups" do
|
103
|
+
Rpbk.setup.config do
|
104
|
+
group :group_name do
|
105
|
+
set :key => :variable1, :key2 => :variable1
|
106
|
+
end
|
107
|
+
group :group2_name do
|
108
|
+
set :key => :variable, :key2 => :variable2
|
109
|
+
end
|
110
|
+
controller :controller_name, :extend => [:group_name, :group2_name] do
|
111
|
+
end
|
112
|
+
end
|
113
|
+
Rpbk.find(:key, :controller_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
114
|
+
Rpbk.find(:key2, :controller_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
115
|
+
end
|
116
|
+
it "should be able extend many controllers" do
|
117
|
+
Rpbk.setup.config do
|
118
|
+
controller :controller3_name do
|
119
|
+
set :key => :variable3, :key2 => :variable3
|
120
|
+
end
|
121
|
+
controller :controller_name do
|
122
|
+
set :key => :variable1, :key2 => :variable2
|
123
|
+
end
|
124
|
+
controller :controller2_name, :extend => [:controller3_name, :controller_name] do
|
125
|
+
set :key => :variable
|
126
|
+
end
|
127
|
+
end
|
128
|
+
Rpbk.find(:key, :controller2_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
129
|
+
Rpbk.find(:key2, :controller2_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
130
|
+
|
131
|
+
end
|
132
|
+
it "should work without block" do
|
133
|
+
Rpbk.setup.config do
|
134
|
+
group :group_name do
|
135
|
+
set :key => :variable1, :key2 => :variable2
|
136
|
+
end
|
137
|
+
controller :controller_name, :extend => :group_name
|
138
|
+
controller :controller2_name
|
139
|
+
end
|
140
|
+
Rpbk.find(:key, :controller_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
141
|
+
Rpbk.find(:key2, :controller_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
142
|
+
Rpbk.find(:key, :controller2_name).should be_nil
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "#group" do
|
147
|
+
it "should add data to groups" do
|
148
|
+
Rpbk.setup.config do
|
149
|
+
group :group_name do
|
150
|
+
set :key => :variable
|
151
|
+
end
|
152
|
+
end
|
153
|
+
Rpbk.find(:key).should be_nil
|
154
|
+
Rpbk.config.find_in_group(:key, :group_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
155
|
+
end
|
156
|
+
it "should be able extend any group" do
|
157
|
+
Rpbk.setup.config do
|
158
|
+
group :group_name do
|
159
|
+
set :key => :variable1, :key2 => :variable2
|
160
|
+
end
|
161
|
+
group :group2_name, :extend => :group_name do
|
162
|
+
set :key => :variable
|
163
|
+
end
|
164
|
+
end
|
165
|
+
Rpbk.config.find_in_group(:key, :group2_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
166
|
+
Rpbk.config.find_in_group(:key2, :group2_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "#action" do
|
171
|
+
it "should be in controller block" do
|
172
|
+
expect {
|
173
|
+
Rpbk.setup.config do
|
174
|
+
action :action_name do
|
175
|
+
set :key => :variable
|
176
|
+
end
|
177
|
+
end
|
178
|
+
}.to raise_error(
|
179
|
+
Rpbk::ActionControllerNotSpecifiedException, /action_name should have an controller/
|
180
|
+
)
|
181
|
+
end
|
182
|
+
it "should add data to controller action" do
|
183
|
+
Rpbk.setup.config do
|
184
|
+
controller :controller_name do
|
185
|
+
action :action_name do
|
186
|
+
set :key => :variable
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
Rpbk.find(:key).should be_nil
|
191
|
+
Rpbk.find(:key, :controller_name).should be_nil
|
192
|
+
Rpbk.find(:key, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
193
|
+
end
|
194
|
+
it "should be able extend any group" do
|
195
|
+
Rpbk.setup.config do
|
196
|
+
group :group_name do
|
197
|
+
set :key => :variable1, :key2 => :variable2
|
198
|
+
end
|
199
|
+
controller :controller_name do
|
200
|
+
action :action_name, :extend => :group_name do
|
201
|
+
set :key => :variable
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
Rpbk.find(:key, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
206
|
+
Rpbk.find(:key2, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
207
|
+
end
|
208
|
+
it "should be able extend any controller" do
|
209
|
+
Rpbk.setup.config do
|
210
|
+
controller :controller_name do
|
211
|
+
set :key => :variable1, :key2 => :variable2
|
212
|
+
end
|
213
|
+
controller :controller2_name do
|
214
|
+
action :action_name, :extend => :controller_name do
|
215
|
+
set :key => :variable
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
Rpbk.find(:key, :controller2_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
220
|
+
Rpbk.find(:key2, :controller2_name, :action_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
221
|
+
end
|
222
|
+
it "should be able extend action in the same controller" do
|
223
|
+
Rpbk.setup.config do
|
224
|
+
controller :controller_name do
|
225
|
+
action :action_name2 do
|
226
|
+
set :key => :variable1, :key2 => :variable2
|
227
|
+
end
|
228
|
+
action :action_name, :extend => :action_name2 do
|
229
|
+
set :key => :variable
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
Rpbk.find(:key, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
234
|
+
Rpbk.find(:key2, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
235
|
+
end
|
236
|
+
it "should be able extend many groups" do
|
237
|
+
Rpbk.setup.config do
|
238
|
+
group :group2_name do
|
239
|
+
set :key => :variable3, :key2 => :variable3
|
240
|
+
end
|
241
|
+
group :group_name do
|
242
|
+
set :key => :variable, :key2 => :variable2
|
243
|
+
end
|
244
|
+
controller :controller_name do
|
245
|
+
action :action_name, :extend => [:group2_name, :group_name]
|
246
|
+
end
|
247
|
+
end
|
248
|
+
Rpbk.find(:key, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
249
|
+
Rpbk.find(:key2, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
250
|
+
end
|
251
|
+
it "should be able extend many controllers" do
|
252
|
+
Rpbk.setup.config do
|
253
|
+
controller :controller2_name do
|
254
|
+
set :key => :variable3, :key2 => :variable3
|
255
|
+
end
|
256
|
+
controller :controller_name do
|
257
|
+
set :key => :variable, :key2 => :variable2
|
258
|
+
end
|
259
|
+
controller :controller_name do
|
260
|
+
action :action_name, :extend => [:controller2_name, :controller_name]
|
261
|
+
end
|
262
|
+
end
|
263
|
+
Rpbk.find(:key, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
264
|
+
Rpbk.find(:key2, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
265
|
+
end
|
266
|
+
it "should be able extend many actions in the same controller" do
|
267
|
+
Rpbk.setup.config do
|
268
|
+
controller :controller_name do
|
269
|
+
action :action3_name do
|
270
|
+
set :key => :variable3, :key2 => :variable2
|
271
|
+
end
|
272
|
+
action :action2_name do
|
273
|
+
set :key => :variable
|
274
|
+
end
|
275
|
+
action :action_name, :extend => [:action3_name, :action2_name]
|
276
|
+
end
|
277
|
+
end
|
278
|
+
Rpbk.find(:key, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
279
|
+
Rpbk.find(:key2, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe "#find" do
|
284
|
+
before :each do
|
285
|
+
Rpbk.setup.config do
|
286
|
+
set :key => :variable_to_rewrite
|
287
|
+
set :key => :variable
|
288
|
+
set :key5 => :main_are_variable
|
289
|
+
controller :controller_name do
|
290
|
+
set :key5 => :controller_variable
|
291
|
+
set :key2 => :vaiable2
|
292
|
+
action :action_name do
|
293
|
+
set :key3 => :variable3
|
294
|
+
end
|
295
|
+
end
|
296
|
+
group :group_name do
|
297
|
+
set :key4 => :variable4
|
298
|
+
end
|
299
|
+
set :key6 => :variable6, :key7 => :variable7
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should add more than one attribute" do
|
304
|
+
Rpbk.find(:key6).should equal(Rpbk::Attribute.new(:key6, :variable6))
|
305
|
+
Rpbk.find(:key7).should equal(Rpbk::Attribute.new(:key7, :variable7))
|
306
|
+
end
|
307
|
+
|
308
|
+
it "should return attribute from controller even it have same in main area" do
|
309
|
+
Rpbk.find(:key5, :controller_name).should equal(Rpbk::Attribute.new(:key5, :main_area_variable))
|
310
|
+
end
|
311
|
+
|
312
|
+
it "should revrite attribute with last one" do
|
313
|
+
Rpbk.find(:key).should equal(Rpbk::Attribute.new(:key, :variable))
|
314
|
+
end
|
315
|
+
|
316
|
+
it "should return attribute from main area" do
|
317
|
+
Rpbk.find(:key).should equal(Rpbk::Attribute.new(:key, :variable))
|
318
|
+
end
|
319
|
+
|
320
|
+
it "should retrun attribute from main area if not found in controller" do
|
321
|
+
Rpbk.find(:key, :controller_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
322
|
+
end
|
323
|
+
|
324
|
+
it "should retrun attribute from main area if not found in controller and in action" do
|
325
|
+
Rpbk.find(:key, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key, :variable))
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should retrun attribute from controller if not found in action" do
|
329
|
+
Rpbk.find(:key2, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
330
|
+
end
|
331
|
+
|
332
|
+
it "should return attribute from controller" do
|
333
|
+
Rpbk.find(:key2, :controller_name).should equal(Rpbk::Attribute.new(:key2, :variable2))
|
334
|
+
end
|
335
|
+
|
336
|
+
it "should return attribute from action" do
|
337
|
+
Rpbk.find(:key3, :controller_name, :action_name).should equal(Rpbk::Attribute.new(:key3, :variable3))
|
338
|
+
end
|
339
|
+
|
340
|
+
it "should return attribute from group" do
|
341
|
+
Rpbk.config.find_in_group(:key4, :group_name).should equal(Rpbk::Attribute.new(:key4, :variable4))
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should not return attribute which is in group if we are looking in main area, controller or action" do
|
345
|
+
Rpbk.find(:key4).should be_nil
|
346
|
+
Rpbk.find(:key4, :controller_name).should be_nil
|
347
|
+
Rpbk.find(:key4, :controller_name, :action_name).should be_nil
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|