dynamic_menus 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +19 -0
- data/Gemfile.lock +77 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +31 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/app/controllers/dynamic_menus_controller.rb +90 -0
- data/app/models/dynamic_menu.rb +28 -0
- data/app/views/dynamic_menus/_form.html.haml +47 -0
- data/app/views/dynamic_menus/edit.html.haml +3 -0
- data/app/views/dynamic_menus/index.html.haml +29 -0
- data/app/views/dynamic_menus/new.html.haml +3 -0
- data/app/views/dynamic_menus/show.html.haml +19 -0
- data/app/views/error_no_access.html.haml +3 -0
- data/dynamic_menus.gemspec +105 -0
- data/lib/dynamic_menus.rb +153 -0
- data/lib/dynamic_menus/version.rb +3 -0
- data/lib/tasks/dynamic_menus_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +8 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.haml +16 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -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 +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -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 +60 -0
- data/test/dummy/db/migrate/20130311085618_create_users.rb +10 -0
- data/test/dummy/db/migrate/20130311085700_create_dynamic_menus.rb +9 -0
- data/test/dummy/db/schema.rb +41 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.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 +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/users.yml +9 -0
- data/test/dummy/test/unit/user_test.rb +7 -0
- data/test/dynamic_menus_test.rb +104 -0
- data/test/test_helper.rb +15 -0
- metadata +171 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20130311085700) do
|
15
|
+
|
16
|
+
create_table "dynamic_menu_translations", :force => true do |t|
|
17
|
+
t.integer "dynamic_menu_id"
|
18
|
+
t.string "locale"
|
19
|
+
t.string "title"
|
20
|
+
t.datetime "created_at", :null => false
|
21
|
+
t.datetime "updated_at", :null => false
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index "dynamic_menu_translations", ["dynamic_menu_id"], :name => "index_dynamic_menu_translations_on_dynamic_menu_id"
|
25
|
+
add_index "dynamic_menu_translations", ["locale"], :name => "index_dynamic_menu_translations_on_locale"
|
26
|
+
|
27
|
+
create_table "dynamic_menus", :force => true do |t|
|
28
|
+
t.integer "dynamic_menu_id"
|
29
|
+
t.string "idstr"
|
30
|
+
t.string "url"
|
31
|
+
t.integer "sort"
|
32
|
+
end
|
33
|
+
|
34
|
+
create_table "users", :force => true do |t|
|
35
|
+
t.string "username"
|
36
|
+
t.string "password"
|
37
|
+
t.datetime "created_at", :null => false
|
38
|
+
t.datetime "updated_at", :null => false
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
File without changes
|
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,25 @@
|
|
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
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</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,104 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DynamicMenusTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
DynamicMenus.create_tables
|
6
|
+
end
|
7
|
+
|
8
|
+
test "truth" do
|
9
|
+
assert_kind_of Module, DynamicMenus
|
10
|
+
end
|
11
|
+
|
12
|
+
test "should validate write access" do
|
13
|
+
DynamicMenus.on_validate_write_access{ true }
|
14
|
+
assert_equal DynamicMenus.write_access?, true
|
15
|
+
|
16
|
+
DynamicMenus.on_validate_write_access{ false }
|
17
|
+
assert_equal DynamicMenus.write_access?, false
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should do validate show through validate_show method" do
|
21
|
+
test_menu = DynamicMenu.create(
|
22
|
+
idstr: :validate_show_menu
|
23
|
+
)
|
24
|
+
|
25
|
+
found = false
|
26
|
+
DynamicMenus.recursive_walkthrough do |data|
|
27
|
+
if data[:menu].id.to_i == test_menu.id.to_i
|
28
|
+
found = true
|
29
|
+
break
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_equal found, true
|
34
|
+
|
35
|
+
DynamicMenus.connect(mode: :validate_show, idstr: :validate_show_menu) do
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
found = false
|
40
|
+
DynamicMenus.recursive_walkthrough do |data|
|
41
|
+
if data[:menu].id.to_i == test_menu.id.to_i
|
42
|
+
found = true
|
43
|
+
break
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_equal found, true
|
48
|
+
|
49
|
+
DynamicMenus.connect(mode: :validate_show, idstr: :validate_show_menu) do
|
50
|
+
false
|
51
|
+
end
|
52
|
+
|
53
|
+
found = false
|
54
|
+
DynamicMenus.recursive_walkthrough do |data|
|
55
|
+
if data[:menu].id.to_i == test_menu.id.to_i
|
56
|
+
found = false
|
57
|
+
break
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_equal found, false
|
62
|
+
end
|
63
|
+
|
64
|
+
test "should do validate show through check_callback" do
|
65
|
+
test_menu = DynamicMenu.create(
|
66
|
+
idstr: :validate_show_menu_check_callback,
|
67
|
+
check_callbacks: "test, test2"
|
68
|
+
)
|
69
|
+
|
70
|
+
test_found = false
|
71
|
+
test2_found = false
|
72
|
+
test_menu.check_callbacks_enum.each do |symb|
|
73
|
+
test_found = true if symb == :test
|
74
|
+
test2_found = true if symb == :test2
|
75
|
+
end
|
76
|
+
|
77
|
+
assert_equal true, test_found
|
78
|
+
assert_equal true, test2_found
|
79
|
+
|
80
|
+
found = false
|
81
|
+
DynamicMenus.recursive_walkthrough do |data|
|
82
|
+
if data[:menu].id.to_i == test_menu.id.to_i
|
83
|
+
found = true
|
84
|
+
break
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
assert_equal true, found
|
89
|
+
|
90
|
+
DynamicMenus.connect(mode: :check_callback, idstr: :test2) do
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
found = false
|
95
|
+
DynamicMenus.recursive_walkthrough do |data|
|
96
|
+
if data[:menu].id.to_i == test_menu.id.to_i
|
97
|
+
found = true
|
98
|
+
break
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
assert_equal false, found
|
103
|
+
end
|
104
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynamic_menus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- kaspernj
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
16
|
+
name: dynamic_menus
|
17
|
+
type: :runtime
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
none: false
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ! '>='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
none: false
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
prerelease: false
|
32
|
+
name: jeweler
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
none: false
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
none: false
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
prerelease: false
|
48
|
+
name: jquery-rails
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
none: false
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
none: false
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
prerelease: false
|
64
|
+
name: sqlite3
|
65
|
+
type: :development
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
none: false
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
none: false
|
78
|
+
description: Various helpers to create dynamic menus in Rails.
|
79
|
+
email: k@spernj.org
|
80
|
+
executables: []
|
81
|
+
extensions: []
|
82
|
+
extra_rdoc_files:
|
83
|
+
- README.rdoc
|
84
|
+
files:
|
85
|
+
- Gemfile
|
86
|
+
- Gemfile.lock
|
87
|
+
- MIT-LICENSE
|
88
|
+
- README.rdoc
|
89
|
+
- Rakefile
|
90
|
+
- VERSION
|
91
|
+
- app/controllers/dynamic_menus_controller.rb
|
92
|
+
- app/models/dynamic_menu.rb
|
93
|
+
- app/views/dynamic_menus/_form.html.haml
|
94
|
+
- app/views/dynamic_menus/edit.html.haml
|
95
|
+
- app/views/dynamic_menus/index.html.haml
|
96
|
+
- app/views/dynamic_menus/new.html.haml
|
97
|
+
- app/views/dynamic_menus/show.html.haml
|
98
|
+
- app/views/error_no_access.html.haml
|
99
|
+
- dynamic_menus.gemspec
|
100
|
+
- lib/dynamic_menus.rb
|
101
|
+
- lib/dynamic_menus/version.rb
|
102
|
+
- lib/tasks/dynamic_menus_tasks.rake
|
103
|
+
- test/dummy/README.rdoc
|
104
|
+
- test/dummy/Rakefile
|
105
|
+
- test/dummy/app/assets/javascripts/application.js
|
106
|
+
- test/dummy/app/assets/stylesheets/application.css
|
107
|
+
- test/dummy/app/controllers/application_controller.rb
|
108
|
+
- test/dummy/app/helpers/application_helper.rb
|
109
|
+
- test/dummy/app/mailers/.gitkeep
|
110
|
+
- test/dummy/app/models/.gitkeep
|
111
|
+
- test/dummy/app/models/user.rb
|
112
|
+
- test/dummy/app/views/layouts/application.html.haml
|
113
|
+
- test/dummy/config.ru
|
114
|
+
- test/dummy/config/application.rb
|
115
|
+
- test/dummy/config/boot.rb
|
116
|
+
- test/dummy/config/database.yml
|
117
|
+
- test/dummy/config/environment.rb
|
118
|
+
- test/dummy/config/environments/development.rb
|
119
|
+
- test/dummy/config/environments/production.rb
|
120
|
+
- test/dummy/config/environments/test.rb
|
121
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
122
|
+
- test/dummy/config/initializers/inflections.rb
|
123
|
+
- test/dummy/config/initializers/mime_types.rb
|
124
|
+
- test/dummy/config/initializers/secret_token.rb
|
125
|
+
- test/dummy/config/initializers/session_store.rb
|
126
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
127
|
+
- test/dummy/config/locales/en.yml
|
128
|
+
- test/dummy/config/routes.rb
|
129
|
+
- test/dummy/db/migrate/20130311085618_create_users.rb
|
130
|
+
- test/dummy/db/migrate/20130311085700_create_dynamic_menus.rb
|
131
|
+
- test/dummy/db/schema.rb
|
132
|
+
- test/dummy/lib/assets/.gitkeep
|
133
|
+
- test/dummy/log/.gitkeep
|
134
|
+
- test/dummy/public/404.html
|
135
|
+
- test/dummy/public/422.html
|
136
|
+
- test/dummy/public/500.html
|
137
|
+
- test/dummy/public/favicon.ico
|
138
|
+
- test/dummy/script/rails
|
139
|
+
- test/dummy/test/fixtures/users.yml
|
140
|
+
- test/dummy/test/unit/user_test.rb
|
141
|
+
- test/dynamic_menus_test.rb
|
142
|
+
- test/test_helper.rb
|
143
|
+
homepage: http://github.com/kaspernj/dynamic_menus
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
hash: -2966163420844003601
|
157
|
+
version: '0'
|
158
|
+
none: false
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
none: false
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 1.8.23
|
168
|
+
signing_key:
|
169
|
+
specification_version: 3
|
170
|
+
summary: Various helpers to create dynamic menus in Rails.
|
171
|
+
test_files: []
|