navi 0.0.17 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +50 -0
- data/.rvmrc +1 -1
- data/Gemfile +1 -46
- data/Gemfile.lock +136 -116
- data/{README.textile → README.md} +32 -28
- data/Rakefile +1 -44
- data/features/step_definitions/category_steps.rb +1 -1
- data/features/step_definitions/page_steps.rb +1 -1
- data/lib/navi.rb +4 -11
- data/lib/navi/navigable/base.rb +1 -0
- data/lib/navi/navigable/instance_methods.rb +27 -1
- data/lib/navi/version.rb +3 -0
- data/navi.gemspec +44 -272
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +7 -0
- data/spec/dummy/{public → app/assets}/javascripts/jquery-ui.js +0 -0
- data/spec/dummy/{public → app/assets}/javascripts/jquery-ui.min.js +0 -0
- data/spec/dummy/{public → app/assets}/javascripts/jquery.js +0 -0
- data/spec/dummy/{public → app/assets}/javascripts/jquery.min.js +0 -0
- data/spec/dummy/{public → app/assets}/javascripts/jquery_ujs.js +0 -0
- data/spec/dummy/{public → app/assets}/javascripts/menu_items/index.js +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/categories_controller.rb +1 -0
- data/spec/dummy/{lib/tasks → app/mailers}/.gitkeep +0 -0
- data/spec/dummy/{public/stylesheets → app/models}/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -1
- data/spec/dummy/app/views/menu_items/index.html.haml +0 -3
- data/spec/dummy/config/application.rb +14 -9
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/database.yml +13 -7
- data/spec/dummy/config/environments/development.rb +7 -3
- data/spec/dummy/config/environments/production.rb +23 -12
- data/spec/dummy/config/environments/test.rb +5 -1
- data/spec/dummy/config/initializers/{navigable.rb → navi.rb} +0 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +1 -1
- data/spec/dummy/config/routes.rb +1 -57
- data/spec/dummy/db/seeds.rb +4 -4
- data/spec/dummy/{vendor/plugins → lib/assets}/.gitkeep +0 -0
- data/spec/factories.rb +15 -0
- data/spec/navi/navi_spec.rb +1 -1
- data/spec/navi/navigable_spec.rb +23 -0
- data/spec/navi/navigator_spec.rb +24 -12
- data/spec/spec_helper.rb +18 -3
- metadata +284 -504
- data/VERSION +0 -1
- data/spec/blueprints.rb +0 -23
- data/spec/dummy/.gitignore +0 -6
- data/spec/dummy/config/cucumber.yml +0 -8
- data/spec/dummy/config/navigation.rb +0 -7
- data/spec/dummy/lib/tasks/cucumber.rake +0 -57
- data/spec/dummy/public/images/rails.png +0 -0
- data/spec/dummy/public/index.html +0 -239
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/rails.js +0 -315
- data/spec/dummy/public/robots.txt +0 -5
- data/spec/dummy/script/cucumber +0 -10
data/spec/dummy/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
1
2
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
3
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
4
|
|
4
5
|
require File.expand_path('../config/application', __FILE__)
|
5
|
-
require 'rake'
|
6
6
|
|
7
7
|
Dummy::Application.load_tasks
|
@@ -0,0 +1,7 @@
|
|
1
|
+
// Place your application-specific JavaScript functions and classes here
|
2
|
+
// This file is automatically included by javascript_include_tag :defaults
|
3
|
+
//= require jquery
|
4
|
+
//= require jquery-ui
|
5
|
+
//= require jquery_ujs
|
6
|
+
//= require 'nestedSortable/jquery.ui.nestedSortable'
|
7
|
+
//= require 'menu_items/index'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
File without changes
|
File without changes
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
require
|
4
|
-
require "active_record/railtie"
|
5
|
-
require "action_controller/railtie"
|
6
|
-
require "action_view/railtie"
|
7
|
-
require "action_mailer/railtie"
|
3
|
+
require 'rails/all'
|
8
4
|
|
9
5
|
Bundler.require
|
10
|
-
|
6
|
+
|
7
|
+
# Don't know why I had to add these here, but did so because
|
8
|
+
# Rails was complaining these things didn't exist.
|
9
|
+
# Shouldn't Bundler be the one to load these in?
|
10
|
+
require "inherited_resources"
|
11
|
+
require "apotomo"
|
11
12
|
|
12
13
|
module Dummy
|
13
14
|
class Application < Rails::Application
|
@@ -33,13 +34,17 @@ module Dummy
|
|
33
34
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
35
|
# config.i18n.default_locale = :de
|
35
36
|
|
36
|
-
# JavaScript files you want as :defaults (application.js is always included).
|
37
|
-
config.action_view.javascript_expansions[:defaults] = %w(jquery jquery-ui.js rails nestedSortable/jquery.ui.nestedSortable.js)
|
38
|
-
|
39
37
|
# Configure the default encoding used in templates for Ruby 1.9.
|
40
38
|
config.encoding = "utf-8"
|
41
39
|
|
42
40
|
# Configure sensitive parameters which will be filtered from the log file.
|
43
41
|
config.filter_parameters += [:password]
|
42
|
+
|
43
|
+
# Enable the asset pipeline
|
44
|
+
config.assets.enabled = true
|
45
|
+
|
46
|
+
# Version of your assets, change this if you want to expire all your assets
|
47
|
+
config.assets.version = '1.0'
|
44
48
|
end
|
45
49
|
end
|
50
|
+
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
# SQLite version 3.x
|
2
2
|
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
3
6
|
development:
|
4
7
|
adapter: sqlite3
|
5
|
-
database:
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
6
11
|
|
7
12
|
# Warning: The database defined as "test" will be erased and
|
8
13
|
# re-generated from your development database when you run "rake".
|
9
14
|
# Do not set this db to the same as development or production.
|
10
|
-
test:
|
15
|
+
test:
|
11
16
|
adapter: sqlite3
|
12
|
-
database:
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
13
20
|
|
14
21
|
production:
|
15
22
|
adapter: sqlite3
|
16
|
-
database:
|
17
|
-
|
18
|
-
|
19
|
-
<<: *test
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -3,7 +3,7 @@ Dummy::Application.configure do
|
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
5
5
|
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
9
|
# Log error messages when you accidentally call methods on nil.
|
@@ -11,7 +11,6 @@ Dummy::Application.configure do
|
|
11
11
|
|
12
12
|
# Show full error reports and disable caching
|
13
13
|
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
14
|
config.action_controller.perform_caching = false
|
16
15
|
|
17
16
|
# Don't care if the mailer can't send
|
@@ -22,5 +21,10 @@ Dummy::Application.configure do
|
|
22
21
|
|
23
22
|
# Only use best-standards-support built into browsers
|
24
23
|
config.action_dispatch.best_standards_support = :builtin
|
25
|
-
end
|
26
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
|
@@ -1,7 +1,6 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb
|
3
3
|
|
4
|
-
# The production environment is meant for finished, "live" apps.
|
5
4
|
# Code is not reloaded between requests
|
6
5
|
config.cache_classes = true
|
7
6
|
|
@@ -9,14 +8,27 @@ Dummy::Application.configure do
|
|
9
8
|
config.consider_all_requests_local = false
|
10
9
|
config.action_controller.perform_caching = true
|
11
10
|
|
12
|
-
#
|
13
|
-
config.
|
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
|
14
22
|
|
15
|
-
#
|
16
|
-
# config.
|
23
|
+
# Defaults to Rails.root.join("public/assets")
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
17
25
|
|
18
|
-
#
|
19
|
-
#
|
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
|
20
32
|
|
21
33
|
# See everything in the log (default is :info)
|
22
34
|
# config.log_level = :debug
|
@@ -27,13 +39,12 @@ Dummy::Application.configure do
|
|
27
39
|
# Use a different cache store in production
|
28
40
|
# config.cache_store = :mem_cache_store
|
29
41
|
|
30
|
-
#
|
31
|
-
# In production, Apache or nginx will already do this
|
32
|
-
config.serve_static_assets = false
|
33
|
-
|
34
|
-
# Enable serving of images, stylesheets, and javascripts from an asset server
|
42
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
35
43
|
# config.action_controller.asset_host = "http://assets.example.com"
|
36
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
|
+
|
37
48
|
# Disable delivery errors, bad email addresses will be ignored
|
38
49
|
# config.action_mailer.raise_delivery_errors = false
|
39
50
|
|
@@ -7,7 +7,11 @@ Dummy::Application.configure do
|
|
7
7
|
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
#
|
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
|
11
15
|
config.whiny_nils = true
|
12
16
|
|
13
17
|
# Show full error reports and disable caching
|
File without changes
|
@@ -4,4 +4,4 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
Dummy::Application.config.secret_token = '
|
7
|
+
Dummy::Application.config.secret_token = '8e022862346d535cb24318751060f3deb41ae4de345e0ee5a827fe9108d13f4927b2b4b51e22e7dd74d68646202b378b97f521b565620822157aa3455764b235'
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Sample localization file for English. Add more files in this directory for other locales.
|
2
|
-
# See
|
2
|
+
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
3
3
|
|
4
4
|
en:
|
5
5
|
hello: "Hello world"
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,61 +1,5 @@
|
|
1
|
-
|
1
|
+
Rails.application.routes.draw do
|
2
2
|
resources :menu_items
|
3
3
|
resources :pages
|
4
4
|
resources :categories
|
5
|
-
# The priority is based upon order of creation:
|
6
|
-
# first created -> highest priority.
|
7
|
-
|
8
|
-
# Sample of regular route:
|
9
|
-
# match 'products/:id' => 'catalog#view'
|
10
|
-
# Keep in mind you can assign values other than :controller and :action
|
11
|
-
|
12
|
-
# Sample of named route:
|
13
|
-
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
14
|
-
# This route can be invoked with purchase_url(:id => product.id)
|
15
|
-
|
16
|
-
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
17
|
-
# resources :products
|
18
|
-
|
19
|
-
# Sample resource route with options:
|
20
|
-
# resources :products do
|
21
|
-
# member do
|
22
|
-
# get 'short'
|
23
|
-
# post 'toggle'
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# collection do
|
27
|
-
# get 'sold'
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
|
31
|
-
# Sample resource route with sub-resources:
|
32
|
-
# resources :products do
|
33
|
-
# resources :comments, :sales
|
34
|
-
# resource :seller
|
35
|
-
# end
|
36
|
-
|
37
|
-
# Sample resource route with more complex sub-resources
|
38
|
-
# resources :products do
|
39
|
-
# resources :comments
|
40
|
-
# resources :sales do
|
41
|
-
# get 'recent', :on => :collection
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
|
45
|
-
# Sample resource route within a namespace:
|
46
|
-
# namespace :admin do
|
47
|
-
# # Directs /admin/products/* to Admin::ProductsController
|
48
|
-
# # (app/controllers/admin/products_controller.rb)
|
49
|
-
# resources :products
|
50
|
-
# end
|
51
|
-
|
52
|
-
# You can have the root of your site routed with "root"
|
53
|
-
# just remember to delete public/index.html.
|
54
|
-
# root :to => "welcome#index"
|
55
|
-
|
56
|
-
# See how all your routes lay out with "rake routes"
|
57
|
-
|
58
|
-
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
59
|
-
# Note: This route will make all actions in every controller accessible via GET requests.
|
60
|
-
# match ':controller(/:action(/:id(.:format)))'
|
61
5
|
end
|
data/spec/dummy/db/seeds.rb
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
|
9
9
|
require '../../spec/blueprints'
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
Factory :page, :name => "Home"
|
12
|
+
Factory :page, :name => "About"
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
Factory :category, :name => "Cars"
|
15
|
+
Factory :category, :name => "Animals"
|
File without changes
|
data/spec/factories.rb
ADDED
data/spec/navi/navi_spec.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Navigable" do
|
4
|
+
context "when deleted" do
|
5
|
+
before do
|
6
|
+
page = Factory :page, :name => "Page name"
|
7
|
+
@menu_item = page.to_navigator!
|
8
|
+
page.destroy
|
9
|
+
@menu_item.reload
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should nullify the navigator's (menu item) pointer to itself" do
|
13
|
+
@menu_item.navigable.should be_nil
|
14
|
+
@menu_item.navigable_id.should be_nil
|
15
|
+
@menu_item.navigable_type.should be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should set the label and url" do
|
19
|
+
@menu_item.label.should == "Page name"
|
20
|
+
@menu_item.url.should == "#"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/navi/navigator_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe MenuItem do
|
|
7
7
|
MenuItem.new.should_not be_valid
|
8
8
|
MenuItem.new(:label => "Something").should_not be_valid
|
9
9
|
MenuItem.new(:url => "Something").should_not be_valid
|
10
|
-
MenuItem.new(:navigable =>
|
10
|
+
MenuItem.new(:navigable => Factory(:page)).should be_valid
|
11
11
|
MenuItem.new(:label => "", :url => "").should_not be_valid
|
12
12
|
MenuItem.new(:label => "Not blank", :url => "Some url").should be_valid
|
13
13
|
end
|
@@ -15,10 +15,22 @@ describe MenuItem do
|
|
15
15
|
|
16
16
|
describe "when configuring ordered_tree" do
|
17
17
|
# After we run the tests, reset the ordered tree changes we may have made
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
before do
|
19
|
+
# Remove the constant to avoid warnings
|
20
|
+
Object.send(:remove_const, :MenuItemDup) if defined?(MenuItemDup)
|
21
|
+
|
22
|
+
# duplicate the MenuItem and modify MenuItem to set back later
|
23
|
+
MenuItemDup = MenuItem.dup
|
24
|
+
MenuItem.class_eval do
|
25
|
+
ordered_tree # set ordered_tree with no args
|
26
|
+
def scope_condition; "1=1"; end # this is the default scope condition in ordered_tree gem
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
after do
|
31
|
+
Object.send :remove_const, :MenuItem
|
32
|
+
MenuItem = MenuItemDup
|
33
|
+
end
|
22
34
|
|
23
35
|
it "should allow overriding of ordered_tree's scope_condition" do
|
24
36
|
MenuItem.class_eval do
|
@@ -26,9 +38,9 @@ describe MenuItem do
|
|
26
38
|
"site_id = #{site_id}"
|
27
39
|
end
|
28
40
|
end
|
29
|
-
|
30
|
-
|
31
|
-
menu_item =
|
41
|
+
Factory(:menu_item, :site_id => 1)
|
42
|
+
Factory(:menu_item, :site_id => 2)
|
43
|
+
menu_item = Factory(:menu_item, :site_id => 1)
|
32
44
|
menu_item.position.should == 2
|
33
45
|
end
|
34
46
|
|
@@ -36,9 +48,9 @@ describe MenuItem do
|
|
36
48
|
MenuItem.class_eval do
|
37
49
|
ordered_tree :scope => :site
|
38
50
|
end
|
39
|
-
|
40
|
-
|
41
|
-
menu_item =
|
51
|
+
Factory(:menu_item, :site_id => 3).position.should == 1
|
52
|
+
Factory(:menu_item, :site_id => 4)
|
53
|
+
menu_item = Factory(:menu_item, :site_id => 3)
|
42
54
|
menu_item.position.should == 2
|
43
55
|
end
|
44
56
|
end
|
@@ -68,7 +80,7 @@ describe MenuItem do
|
|
68
80
|
end
|
69
81
|
end
|
70
82
|
end
|
71
|
-
|
83
|
+
|
72
84
|
describe "and there is no navigable model" do
|
73
85
|
it "should return nil" do
|
74
86
|
MenuItem.new.label.should == nil
|