effective_pages 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +30 -0
  4. data/Rakefile +24 -0
  5. data/app/assets/javascripts/effective_pages.js +0 -0
  6. data/app/assets/stylesheets/effective_pages/dropdown-submenu.css +7 -0
  7. data/app/assets/stylesheets/effective_pages.css.scss +1 -0
  8. data/app/controllers/admin/menus_controller.rb +79 -0
  9. data/app/controllers/admin/pages_controller.rb +95 -0
  10. data/app/controllers/effective/pages_controller.rb +24 -0
  11. data/app/helpers/effective_menus_helper.rb +151 -0
  12. data/app/helpers/effective_pages_helper.rb +14 -0
  13. data/app/models/effective/access_denied.rb +17 -0
  14. data/app/models/effective/datatables/menus.rb +16 -0
  15. data/app/models/effective/datatables/pages.rb +19 -0
  16. data/app/models/effective/menu.rb +152 -0
  17. data/app/models/effective/menu_item.rb +68 -0
  18. data/app/models/effective/page.rb +32 -0
  19. data/app/views/admin/menu_items/_actions.html.haml +4 -0
  20. data/app/views/admin/menu_items/_expand.html.haml +2 -0
  21. data/app/views/admin/menu_items/_item.html.haml +13 -0
  22. data/app/views/admin/menu_items/_new.html.haml +3 -0
  23. data/app/views/admin/menus/_actions.html.haml +4 -0
  24. data/app/views/admin/menus/_form.html.haml +9 -0
  25. data/app/views/admin/menus/edit.html.haml +2 -0
  26. data/app/views/admin/menus/index.html.haml +9 -0
  27. data/app/views/admin/menus/new.html.haml +2 -0
  28. data/app/views/admin/pages/_actions.html.haml +14 -0
  29. data/app/views/admin/pages/_form.html.haml +31 -0
  30. data/app/views/admin/pages/edit.html.haml +2 -0
  31. data/app/views/admin/pages/index.html.haml +9 -0
  32. data/app/views/admin/pages/new.html.haml +2 -0
  33. data/config/routes.rb +28 -0
  34. data/db/migrate/01_create_effective_pages.rb.erb +52 -0
  35. data/lib/effective_pages/engine.rb +19 -0
  36. data/lib/effective_pages/version.rb +3 -0
  37. data/lib/effective_pages.rb +73 -0
  38. data/lib/generators/effective_pages/install_generator.rb +43 -0
  39. data/lib/generators/templates/README +1 -0
  40. data/lib/generators/templates/effective_pages.rb +49 -0
  41. data/lib/generators/templates/example.html.haml +6 -0
  42. data/lib/tasks/effective_pages_tasks.rake +29 -0
  43. data/spec/controllers/effective/pages_controller_spec.rb +66 -0
  44. data/spec/dummy/README.rdoc +261 -0
  45. data/spec/dummy/Rakefile +7 -0
  46. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  47. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  48. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  49. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  50. data/spec/dummy/app/views/effective/pages/example.html.haml +2 -0
  51. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  52. data/spec/dummy/config/application.rb +66 -0
  53. data/spec/dummy/config/boot.rb +10 -0
  54. data/spec/dummy/config/database.yml +25 -0
  55. data/spec/dummy/config/environment.rb +5 -0
  56. data/spec/dummy/config/environments/development.rb +37 -0
  57. data/spec/dummy/config/environments/production.rb +67 -0
  58. data/spec/dummy/config/environments/test.rb +37 -0
  59. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/spec/dummy/config/initializers/inflections.rb +15 -0
  61. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  62. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  63. data/spec/dummy/config/initializers/session_store.rb +8 -0
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/spec/dummy/config/locales/en.yml +5 -0
  66. data/spec/dummy/config/routes.rb +60 -0
  67. data/spec/dummy/config.ru +4 -0
  68. data/spec/dummy/db/migrate/01_create_effective_pages.rb +51 -0
  69. data/spec/dummy/db/schema.rb +52 -0
  70. data/spec/dummy/db/test.sqlite3 +0 -0
  71. data/spec/dummy/public/404.html +26 -0
  72. data/spec/dummy/public/422.html +26 -0
  73. data/spec/dummy/public/500.html +25 -0
  74. data/spec/dummy/public/favicon.ico +0 -0
  75. data/spec/dummy/script/rails +6 -0
  76. data/spec/dummy/spec_link +3 -0
  77. data/spec/effective_pages_spec.rb +7 -0
  78. data/spec/helpers/effective_menus_helper_spec.rb +281 -0
  79. data/spec/models/effective/menu_spec.rb +133 -0
  80. data/spec/spec_helper.rb +43 -0
  81. data/spec/support/factories.rb +15 -0
  82. metadata +261 -0
@@ -0,0 +1,133 @@
1
+ require 'spec_helper'
2
+
3
+ describe Effective::Menu do
4
+ describe 'Effective Menus DSL' do
5
+
6
+ it 'correctly builds a menu with items' do
7
+ menu = Effective::Menu.new(:title => 'test').build do
8
+ item 'AAA'
9
+ item 'BBB'
10
+ end
11
+
12
+ menu.valid?.should eq true
13
+
14
+ items = menu.menu_items.sort_by(&:lft).map { |item| [item.title, item.lft, item.rgt] }
15
+
16
+ expect(items).to eq [
17
+ ['Home', 1, 6],
18
+ ['AAA', 2, 3],
19
+ ['BBB', 4, 5]
20
+ ]
21
+ end
22
+
23
+ it 'correctly builds a menu with dropdowns' do
24
+ menu = Effective::Menu.new(:title => 'test').build do
25
+ dropdown 'About' do
26
+ item 'AAA'
27
+ item 'BBB'
28
+ end
29
+
30
+ dropdown 'Become a Member' do
31
+ item '111'
32
+ item '222'
33
+ end
34
+
35
+ item 'XXX'
36
+ end
37
+
38
+ menu.valid?.should eq true
39
+
40
+ items = menu.menu_items.sort_by(&:lft).map { |item| [item.title, item.lft, item.rgt] }
41
+
42
+ expect(items).to eq [
43
+ ['Home', 1, 16],
44
+ ['About', 2, 7],
45
+ ['AAA', 3, 4],
46
+ ['BBB', 5, 6],
47
+ ['Become a Member', 8, 13],
48
+ ['111', 9, 10],
49
+ ['222', 11, 12],
50
+ ['XXX', 14, 15]
51
+ ]
52
+ end
53
+
54
+ it 'correctly builds a menu with dropdowns inside dropdowns' do
55
+ menu = Effective::Menu.new(:title => 'test').build do
56
+ dropdown 'Fruit' do
57
+ dropdown 'Red' do
58
+ item 'Cherry'
59
+ end
60
+
61
+ dropdown 'Yellow' do
62
+ item 'Banana'
63
+ end
64
+ end
65
+
66
+ dropdown 'Meat' do
67
+ item 'Beef'
68
+ item 'Pork'
69
+ end
70
+ end
71
+
72
+ menu.valid?.should eq true
73
+
74
+ items = menu.menu_items.sort_by(&:lft).map { |item| [item.title, item.lft, item.rgt] }
75
+
76
+ expect(items).to eq [
77
+ ['Home', 1, 18],
78
+ ['Fruit', 2, 11],
79
+ ['Red', 3, 6],
80
+ ['Cherry', 4, 5],
81
+ ['Yellow', 7, 10],
82
+ ['Banana', 8, 9],
83
+ ['Meat', 12, 17],
84
+ ['Beef', 13, 14],
85
+ ['Pork', 15, 16]
86
+ ]
87
+
88
+ end
89
+
90
+ it 'correctly renders dropdowns and items' do
91
+ menu = Effective::Menu.new(:title => 'test').build do
92
+ dropdown 'About' do
93
+ item 'AAA'
94
+ item 'BBB'
95
+ item 'CCC'
96
+ item 'DDD'
97
+ end
98
+
99
+ dropdown 'Events' do
100
+ item 'Conferences'
101
+
102
+ dropdown 'Workshops' do
103
+ dropdown 'AAA' do
104
+ item '111'
105
+ item '222'
106
+ end
107
+ item 'BBB'
108
+ end
109
+ end
110
+ end
111
+
112
+ menu.valid?.should eq true
113
+
114
+ items = menu.menu_items.sort_by(&:lft).map { |item| [item.title, item.lft, item.rgt] }
115
+
116
+ expect(items).to eq [
117
+ ['Home', 1, 26],
118
+ ['About', 2, 11],
119
+ ['AAA', 3, 4],
120
+ ['BBB', 5, 6],
121
+ ['CCC', 7, 8],
122
+ ['DDD', 9, 10],
123
+ ['Events', 12, 25],
124
+ ['Conferences', 13, 14],
125
+ ['Workshops', 15, 24],
126
+ ['AAA', 16, 21],
127
+ ['111', 17, 18],
128
+ ['222', 19, 20],
129
+ ['BBB', 22, 23],
130
+ ]
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,43 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+
5
+ require 'rspec/rails'
6
+ require 'rspec/autorun'
7
+ require 'capybara/rspec'
8
+ require 'capybara/poltergeist'
9
+ require 'factory_girl_rails'
10
+ require 'haml'
11
+
12
+ # Requires supporting ruby files with custom matchers and macros, etc,
13
+ # in spec/support/ and its subdirectories.
14
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f }
15
+
16
+ RSpec.configure do |config|
17
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
18
+
19
+ config.include Capybara::DSL
20
+
21
+ Capybara.current_driver = :poltergeist
22
+ Capybara.javascript_driver = :poltergeist
23
+ Capybara.default_wait_time = 5
24
+
25
+ Rails.logger.level = 4 # Output only minimal stuff to test.log
26
+
27
+ config.use_transactional_fixtures = true # Make this false to once again use DatabaseCleaner
28
+ config.infer_base_class_for_anonymous_controllers = false
29
+ config.order = 'random'
30
+ end
31
+
32
+ class ActiveRecord::Base
33
+ mattr_accessor :shared_connection
34
+ @@shared_connection = nil
35
+
36
+ def self.connection
37
+ @@shared_connection || retrieve_connection
38
+ end
39
+ end
40
+
41
+ # Forces all threads to share the same connection. This works on
42
+ # Capybara because it starts the web server in a thread.
43
+ ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@@ -0,0 +1,15 @@
1
+ require 'factory_girl'
2
+
3
+ FactoryGirl.define do
4
+ factory :page, :class => Effective::Page do
5
+ sequence(:title) { |n| "Title #{n}" }
6
+ sequence(:slug) { |n| "title-#{n}" }
7
+
8
+ meta_description 'meta description'
9
+ draft false
10
+
11
+ template 'example'
12
+ layout 'application'
13
+ end
14
+ end
15
+
metadata ADDED
@@ -0,0 +1,261 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: effective_pages
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
5
+ platform: ruby
6
+ authors:
7
+ - Code and Effect
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: haml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: migrant
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simple_form
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: effective_slugs
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: effective_ckeditor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: effective_regions
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.2.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.2.0
111
+ description: CRUD Pages with intention to work with EffectiveRegions. WIP.
112
+ email:
113
+ - info@codeandeffect.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - MIT-LICENSE
119
+ - README.md
120
+ - Rakefile
121
+ - app/assets/javascripts/effective_pages.js
122
+ - app/assets/stylesheets/effective_pages.css.scss
123
+ - app/assets/stylesheets/effective_pages/dropdown-submenu.css
124
+ - app/controllers/admin/menus_controller.rb
125
+ - app/controllers/admin/pages_controller.rb
126
+ - app/controllers/effective/pages_controller.rb
127
+ - app/helpers/effective_menus_helper.rb
128
+ - app/helpers/effective_pages_helper.rb
129
+ - app/models/effective/access_denied.rb
130
+ - app/models/effective/datatables/menus.rb
131
+ - app/models/effective/datatables/pages.rb
132
+ - app/models/effective/menu.rb
133
+ - app/models/effective/menu_item.rb
134
+ - app/models/effective/page.rb
135
+ - app/views/admin/menu_items/_actions.html.haml
136
+ - app/views/admin/menu_items/_expand.html.haml
137
+ - app/views/admin/menu_items/_item.html.haml
138
+ - app/views/admin/menu_items/_new.html.haml
139
+ - app/views/admin/menus/_actions.html.haml
140
+ - app/views/admin/menus/_form.html.haml
141
+ - app/views/admin/menus/edit.html.haml
142
+ - app/views/admin/menus/index.html.haml
143
+ - app/views/admin/menus/new.html.haml
144
+ - app/views/admin/pages/_actions.html.haml
145
+ - app/views/admin/pages/_form.html.haml
146
+ - app/views/admin/pages/edit.html.haml
147
+ - app/views/admin/pages/index.html.haml
148
+ - app/views/admin/pages/new.html.haml
149
+ - config/routes.rb
150
+ - db/migrate/01_create_effective_pages.rb.erb
151
+ - lib/effective_pages.rb
152
+ - lib/effective_pages/engine.rb
153
+ - lib/effective_pages/version.rb
154
+ - lib/generators/effective_pages/install_generator.rb
155
+ - lib/generators/templates/README
156
+ - lib/generators/templates/effective_pages.rb
157
+ - lib/generators/templates/example.html.haml
158
+ - lib/tasks/effective_pages_tasks.rake
159
+ - spec/controllers/effective/pages_controller_spec.rb
160
+ - spec/dummy/README.rdoc
161
+ - spec/dummy/Rakefile
162
+ - spec/dummy/app/assets/javascripts/application.js
163
+ - spec/dummy/app/assets/stylesheets/application.css
164
+ - spec/dummy/app/controllers/application_controller.rb
165
+ - spec/dummy/app/helpers/application_helper.rb
166
+ - spec/dummy/app/views/effective/pages/example.html.haml
167
+ - spec/dummy/app/views/layouts/application.html.erb
168
+ - spec/dummy/config.ru
169
+ - spec/dummy/config/application.rb
170
+ - spec/dummy/config/boot.rb
171
+ - spec/dummy/config/database.yml
172
+ - spec/dummy/config/environment.rb
173
+ - spec/dummy/config/environments/development.rb
174
+ - spec/dummy/config/environments/production.rb
175
+ - spec/dummy/config/environments/test.rb
176
+ - spec/dummy/config/initializers/backtrace_silencers.rb
177
+ - spec/dummy/config/initializers/inflections.rb
178
+ - spec/dummy/config/initializers/mime_types.rb
179
+ - spec/dummy/config/initializers/secret_token.rb
180
+ - spec/dummy/config/initializers/session_store.rb
181
+ - spec/dummy/config/initializers/wrap_parameters.rb
182
+ - spec/dummy/config/locales/en.yml
183
+ - spec/dummy/config/routes.rb
184
+ - spec/dummy/db/migrate/01_create_effective_pages.rb
185
+ - spec/dummy/db/schema.rb
186
+ - spec/dummy/db/test.sqlite3
187
+ - spec/dummy/public/404.html
188
+ - spec/dummy/public/422.html
189
+ - spec/dummy/public/500.html
190
+ - spec/dummy/public/favicon.ico
191
+ - spec/dummy/script/rails
192
+ - spec/dummy/spec_link
193
+ - spec/effective_pages_spec.rb
194
+ - spec/helpers/effective_menus_helper_spec.rb
195
+ - spec/models/effective/menu_spec.rb
196
+ - spec/spec_helper.rb
197
+ - spec/support/factories.rb
198
+ homepage: https://github.com/code-and-effect/effective_pages
199
+ licenses:
200
+ - MIT
201
+ metadata: {}
202
+ post_install_message:
203
+ rdoc_options: []
204
+ require_paths:
205
+ - lib
206
+ required_ruby_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
211
+ required_rubygems_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ requirements: []
217
+ rubyforge_project:
218
+ rubygems_version: 2.4.3
219
+ signing_key:
220
+ specification_version: 4
221
+ summary: CRUD Pages with intention to work with EffectiveRegions. WIP.
222
+ test_files:
223
+ - spec/controllers/effective/pages_controller_spec.rb
224
+ - spec/dummy/app/assets/javascripts/application.js
225
+ - spec/dummy/app/assets/stylesheets/application.css
226
+ - spec/dummy/app/controllers/application_controller.rb
227
+ - spec/dummy/app/helpers/application_helper.rb
228
+ - spec/dummy/app/views/effective/pages/example.html.haml
229
+ - spec/dummy/app/views/layouts/application.html.erb
230
+ - spec/dummy/config/application.rb
231
+ - spec/dummy/config/boot.rb
232
+ - spec/dummy/config/database.yml
233
+ - spec/dummy/config/environment.rb
234
+ - spec/dummy/config/environments/development.rb
235
+ - spec/dummy/config/environments/production.rb
236
+ - spec/dummy/config/environments/test.rb
237
+ - spec/dummy/config/initializers/backtrace_silencers.rb
238
+ - spec/dummy/config/initializers/inflections.rb
239
+ - spec/dummy/config/initializers/mime_types.rb
240
+ - spec/dummy/config/initializers/secret_token.rb
241
+ - spec/dummy/config/initializers/session_store.rb
242
+ - spec/dummy/config/initializers/wrap_parameters.rb
243
+ - spec/dummy/config/locales/en.yml
244
+ - spec/dummy/config/routes.rb
245
+ - spec/dummy/config.ru
246
+ - spec/dummy/db/migrate/01_create_effective_pages.rb
247
+ - spec/dummy/db/schema.rb
248
+ - spec/dummy/db/test.sqlite3
249
+ - spec/dummy/public/404.html
250
+ - spec/dummy/public/422.html
251
+ - spec/dummy/public/500.html
252
+ - spec/dummy/public/favicon.ico
253
+ - spec/dummy/Rakefile
254
+ - spec/dummy/README.rdoc
255
+ - spec/dummy/script/rails
256
+ - spec/dummy/spec_link
257
+ - spec/effective_pages_spec.rb
258
+ - spec/helpers/effective_menus_helper_spec.rb
259
+ - spec/models/effective/menu_spec.rb
260
+ - spec/spec_helper.rb
261
+ - spec/support/factories.rb