brightcontent-core 2.0.30 → 2.0.31

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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile.lock +69 -82
  3. data/app/assets/javascripts/brightcontent/brightcontent.js +0 -1
  4. data/app/assets/javascripts/brightcontent/main.js +4 -3
  5. data/app/assets/stylesheets/brightcontent/main.css +16 -1
  6. data/app/controllers/brightcontent/admin_users_controller.rb +3 -0
  7. data/app/controllers/brightcontent/application_controller.rb +3 -3
  8. data/app/controllers/brightcontent/base_controller.rb +7 -5
  9. data/app/helpers/brightcontent/base_helper.rb +9 -2
  10. data/app/views/brightcontent/application/_menu.html.erb +2 -2
  11. data/app/views/brightcontent/application/_show_flash_names.html.erb +1 -1
  12. data/app/views/brightcontent/base/_form.html.erb +12 -5
  13. data/app/views/brightcontent/base/_list_actions.html.erb +2 -2
  14. data/app/views/brightcontent/base/edit.html.erb +1 -1
  15. data/app/views/brightcontent/base/index.csv.erb +1 -1
  16. data/app/views/brightcontent/base/index.html.erb +2 -2
  17. data/app/views/brightcontent/fields/_file.html.erb +6 -0
  18. data/brightcontent-core.gemspec +2 -2
  19. data/config/locales/brightcontent.en.yml +10 -0
  20. data/config/locales/brightcontent.nl.yml +10 -0
  21. data/lib/brightcontent/default_actions.rb +11 -3
  22. data/lib/brightcontent/routes_parser.rb +23 -9
  23. data/spec/dummy/app/controllers/brightcontent/comments_controller.rb +3 -0
  24. data/spec/dummy/app/models/blog.rb +1 -0
  25. data/spec/dummy/app/models/comment.rb +3 -0
  26. data/spec/dummy/config/routes.rb +3 -1
  27. data/spec/dummy/db/migrate/20130720211920_create_comments.rb +12 -0
  28. data/spec/dummy/db/schema.rb +10 -1
  29. data/spec/dummy/test/fixtures/comments.yml +11 -0
  30. data/spec/dummy/test/unit/comments_test.rb +7 -0
  31. data/spec/factories.rb +1 -1
  32. data/spec/features/nested_resource_spec.rb +50 -0
  33. data/spec/features/resources_index_spec.rb +1 -1
  34. data/spec/lib/brightcontent/routes_parser_spec.rb +13 -8
  35. metadata +52 -74
  36. data/lib/brightcontent/strong_params_fix.rb +0 -16
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b14c5e3e5868779efe399929d61b1c1b6370865d
4
+ data.tar.gz: 042f496e3c714b54896d95ee48a02a173d29fc63
5
+ SHA512:
6
+ metadata.gz: 567b8186b474923724f93b6a681fe72bad14432bd9ec2f6f04d4c171a6585a4e20e5a42318a1aca3f1ecf00f7bce3aeea119d0bc6bd9f08fd624cde9d9e85be3
7
+ data.tar.gz: c55958d7cf3394301a00cf52c2d1866b838fcf1a31e88662f06516aa80baf36e38b16e696debf651a0d9a9d85fc756ed8e1406b3f8b31b0caa3ad369d5efd842
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightcontent-core (2.0.30)
5
- bcrypt-ruby
4
+ brightcontent-core (2.0.31)
5
+ bcrypt-ruby (= 3.0.0)
6
6
  bootstrap-wysihtml5-rails
7
7
  has_scope
8
8
  inherited_resources
9
9
  jquery-rails
10
- rails (~> 3.2.9)
10
+ rails (~> 3.2.13)
11
11
  simple_form
12
12
  strong_parameters
13
13
  will_paginate
@@ -15,124 +15,112 @@ PATH
15
15
  GEM
16
16
  remote: http://rubygems.org/
17
17
  specs:
18
- actionmailer (3.2.9)
19
- actionpack (= 3.2.9)
20
- mail (~> 2.4.4)
21
- actionpack (3.2.9)
22
- activemodel (= 3.2.9)
23
- activesupport (= 3.2.9)
18
+ actionmailer (3.2.13)
19
+ actionpack (= 3.2.13)
20
+ mail (~> 2.5.3)
21
+ actionpack (3.2.13)
22
+ activemodel (= 3.2.13)
23
+ activesupport (= 3.2.13)
24
24
  builder (~> 3.0.0)
25
25
  erubis (~> 2.7.0)
26
26
  journey (~> 1.0.4)
27
- rack (~> 1.4.0)
27
+ rack (~> 1.4.5)
28
28
  rack-cache (~> 1.2)
29
29
  rack-test (~> 0.6.1)
30
30
  sprockets (~> 2.2.1)
31
- activemodel (3.2.9)
32
- activesupport (= 3.2.9)
31
+ activemodel (3.2.13)
32
+ activesupport (= 3.2.13)
33
33
  builder (~> 3.0.0)
34
- activerecord (3.2.9)
35
- activemodel (= 3.2.9)
36
- activesupport (= 3.2.9)
34
+ activerecord (3.2.13)
35
+ activemodel (= 3.2.13)
36
+ activesupport (= 3.2.13)
37
37
  arel (~> 3.0.2)
38
38
  tzinfo (~> 0.3.29)
39
- activeresource (3.2.9)
40
- activemodel (= 3.2.9)
41
- activesupport (= 3.2.9)
42
- activesupport (3.2.9)
43
- i18n (~> 0.6)
39
+ activeresource (3.2.13)
40
+ activemodel (= 3.2.13)
41
+ activesupport (= 3.2.13)
42
+ activesupport (3.2.13)
43
+ i18n (= 0.6.1)
44
44
  multi_json (~> 1.0)
45
- addressable (2.3.2)
45
+ addressable (2.3.5)
46
46
  arel (3.0.2)
47
- bcrypt-ruby (3.0.1)
48
- bootstrap-wysihtml5-rails (0.3.1.19)
47
+ bcrypt-ruby (3.0.0)
48
+ bootstrap-wysihtml5-rails (0.3.1.20)
49
49
  railties (>= 3.0)
50
50
  builder (3.0.4)
51
- capybara (2.0.1)
51
+ capybara (2.1.0)
52
52
  mime-types (>= 1.16)
53
53
  nokogiri (>= 1.3.3)
54
54
  rack (>= 1.0.0)
55
55
  rack-test (>= 0.5.4)
56
- selenium-webdriver (~> 2.0)
57
- xpath (~> 1.0.0)
58
- childprocess (0.3.6)
59
- ffi (~> 1.0, >= 1.0.6)
60
- diff-lcs (1.1.3)
56
+ xpath (~> 2.0)
57
+ diff-lcs (1.2.4)
61
58
  erubis (2.7.0)
62
- factory_girl (4.1.0)
59
+ factory_girl (4.2.0)
63
60
  activesupport (>= 3.0.0)
64
- factory_girl_rails (4.1.0)
65
- factory_girl (~> 4.1.0)
61
+ factory_girl_rails (4.2.1)
62
+ factory_girl (~> 4.2.0)
66
63
  railties (>= 3.0.0)
67
- ffi (1.2.0)
68
64
  has_scope (0.5.1)
69
- hike (1.2.1)
65
+ hike (1.2.3)
70
66
  i18n (0.6.1)
71
- inherited_resources (1.3.1)
67
+ inherited_resources (1.4.0)
72
68
  has_scope (~> 0.5.0)
73
- responders (~> 0.6)
69
+ responders (~> 0.9)
74
70
  journey (1.0.4)
75
- jquery-rails (2.2.1)
71
+ jquery-rails (3.0.4)
76
72
  railties (>= 3.0, < 5.0)
77
73
  thor (>= 0.14, < 2.0)
78
- json (1.7.5)
79
- launchy (2.1.2)
74
+ json (1.8.0)
75
+ launchy (2.3.0)
80
76
  addressable (~> 2.3)
81
- libwebsocket (0.1.7.1)
82
- addressable
83
- websocket
84
- mail (2.4.4)
85
- i18n (>= 0.4.0)
77
+ mail (2.5.4)
86
78
  mime-types (~> 1.16)
87
79
  treetop (~> 1.4.8)
88
- mime-types (1.19)
89
- multi_json (1.5.0)
90
- nokogiri (1.5.6)
80
+ mime-types (1.23)
81
+ mini_portile (0.5.1)
82
+ multi_json (1.7.7)
83
+ nokogiri (1.6.0)
84
+ mini_portile (~> 0.5.0)
91
85
  polyglot (0.3.3)
92
- rack (1.4.1)
86
+ rack (1.4.5)
93
87
  rack-cache (1.2)
94
88
  rack (>= 0.4)
95
- rack-ssl (1.3.2)
89
+ rack-ssl (1.3.3)
96
90
  rack
97
91
  rack-test (0.6.2)
98
92
  rack (>= 1.0)
99
- rails (3.2.9)
100
- actionmailer (= 3.2.9)
101
- actionpack (= 3.2.9)
102
- activerecord (= 3.2.9)
103
- activeresource (= 3.2.9)
104
- activesupport (= 3.2.9)
93
+ rails (3.2.13)
94
+ actionmailer (= 3.2.13)
95
+ actionpack (= 3.2.13)
96
+ activerecord (= 3.2.13)
97
+ activeresource (= 3.2.13)
98
+ activesupport (= 3.2.13)
105
99
  bundler (~> 1.0)
106
- railties (= 3.2.9)
107
- railties (3.2.9)
108
- actionpack (= 3.2.9)
109
- activesupport (= 3.2.9)
100
+ railties (= 3.2.13)
101
+ railties (3.2.13)
102
+ actionpack (= 3.2.13)
103
+ activesupport (= 3.2.13)
110
104
  rack-ssl (~> 1.3.2)
111
105
  rake (>= 0.8.7)
112
106
  rdoc (~> 3.4)
113
107
  thor (>= 0.14.6, < 2.0)
114
- rake (10.0.3)
115
- rdoc (3.12)
108
+ rake (10.1.0)
109
+ rdoc (3.12.2)
116
110
  json (~> 1.4)
117
111
  responders (0.9.3)
118
112
  railties (~> 3.1)
119
- rspec-core (2.12.2)
120
- rspec-expectations (2.12.1)
121
- diff-lcs (~> 1.1.3)
122
- rspec-mocks (2.12.1)
123
- rspec-rails (2.12.0)
113
+ rspec-core (2.14.3)
114
+ rspec-expectations (2.14.0)
115
+ diff-lcs (>= 1.1.3, < 2.0)
116
+ rspec-mocks (2.14.1)
117
+ rspec-rails (2.14.0)
124
118
  actionpack (>= 3.0)
125
119
  activesupport (>= 3.0)
126
120
  railties (>= 3.0)
127
- rspec-core (~> 2.12.0)
128
- rspec-expectations (~> 2.12.0)
129
- rspec-mocks (~> 2.12.0)
130
- rubyzip (0.9.9)
131
- selenium-webdriver (2.27.2)
132
- childprocess (>= 0.2.5)
133
- libwebsocket (~> 0.1.3)
134
- multi_json (~> 1.0)
135
- rubyzip
121
+ rspec-core (~> 2.14.0)
122
+ rspec-expectations (~> 2.14.0)
123
+ rspec-mocks (~> 2.14.0)
136
124
  simple_form (2.1.0)
137
125
  actionpack (~> 3.0)
138
126
  activemodel (~> 3.0)
@@ -141,20 +129,19 @@ GEM
141
129
  multi_json (~> 1.0)
142
130
  rack (~> 1.0)
143
131
  tilt (~> 1.1, != 1.3.0)
144
- sqlite3 (1.3.6)
145
- strong_parameters (0.2.0)
132
+ sqlite3 (1.3.7)
133
+ strong_parameters (0.2.1)
146
134
  actionpack (~> 3.0)
147
135
  activemodel (~> 3.0)
148
136
  railties (~> 3.0)
149
- thor (0.16.0)
150
- tilt (1.3.3)
151
- treetop (1.4.12)
137
+ thor (0.18.1)
138
+ tilt (1.4.1)
139
+ treetop (1.4.14)
152
140
  polyglot
153
141
  polyglot (>= 0.3.1)
154
142
  tzinfo (0.3.37)
155
- websocket (1.0.6)
156
143
  will_paginate (3.0.4)
157
- xpath (1.0.0)
144
+ xpath (2.0.0)
158
145
  nokogiri (~> 1.3)
159
146
 
160
147
  PLATFORMS
@@ -16,5 +16,4 @@
16
16
  //= require bootstrap-wysihtml5/locales/nl-NL
17
17
  //= require brightcontent/attachments
18
18
  //= require brightcontent/custom
19
- //= require pages
20
19
  //= require_tree .
@@ -1,8 +1,9 @@
1
1
  $(document).ready(function(){
2
- $('textarea').each(function(i, elem) {
2
+ $('textarea[name*="content"], textarea[name*="body"], textarea[name*="editor"]').each(function(i, elem) {
3
3
  $(elem).wysihtml5({
4
4
  html: true,
5
5
  locale: "nl-NL",
6
+ parserRules: wysihtml5ParserRules,
6
7
  "events": {
7
8
  "load": function() {
8
9
  editor = $('#insertable').data("wysihtml5").editor;
@@ -12,13 +13,13 @@ $(document).ready(function(){
12
13
  });
13
14
  });
14
15
 
15
- $(".insert_image").live("click", function(e){
16
+ $("#attachments").on("click", ".insert_image", function(e){
16
17
  e.preventDefault();
17
18
  console.log($(this).data("insertImage"));
18
19
  editor.composer.commands.exec("insertImage", { src: $(this).data("insertImage") });
19
20
  });
20
21
 
21
- $(".insert_link").live("click", function(e){
22
+ $("#attachments").on("click", ".insert_link", function(e){
22
23
  e.preventDefault();
23
24
  console.log($(this).data());
24
25
  editor.composer.commands.exec("createLink", { href: $(this).data("insertUrl"), target: "_blank", rel: "nofollow", text: $(this).data("insertName") });
@@ -1,4 +1,3 @@
1
- /*=require pages */
2
1
  body {
3
2
  background-color: #f5f5f5;
4
3
  }
@@ -9,6 +8,10 @@ body {
9
8
  max-width: 622px;
10
9
  }
11
10
 
11
+ .form-inputs input[type=checkbox] {
12
+ width: auto;
13
+ }
14
+
12
15
  .btn-right {
13
16
  float: right;
14
17
  }
@@ -78,3 +81,15 @@ td.list-actions {
78
81
  overflow: hidden;
79
82
  padding: 5px 10px;
80
83
  }
84
+
85
+ .file-preview img {
86
+ border: 1px solid #ccc;
87
+ }
88
+
89
+ .delete {
90
+ float: right;
91
+ }
92
+
93
+ select.datetime {
94
+ width: 116px
95
+ }
@@ -2,5 +2,8 @@ require_dependency "brightcontent/application_controller"
2
2
 
3
3
  module Brightcontent
4
4
  class AdminUsersController < BaseController
5
+ def form_fields
6
+ %w( email password )
7
+ end
5
8
  end
6
9
  end
@@ -9,10 +9,10 @@ module Brightcontent
9
9
  end
10
10
  helper_method :current_user
11
11
 
12
- def resource_paths
13
- @resource_paths ||= RoutesParser.parse
12
+ def user_resources
13
+ @user_resources ||= RoutesParser.new.resources
14
14
  end
15
- helper_method :resource_paths
15
+ helper_method :user_resources
16
16
 
17
17
  def authorize
18
18
  redirect_to login_url if current_user.nil?
@@ -10,10 +10,11 @@ module Brightcontent
10
10
  include DefaultActions
11
11
  include Pagination
12
12
 
13
- # Temp until inherent resources supports strong params
14
- include StrongParamsFix
13
+ def permitted_params
14
+ params.permit!
15
+ end
15
16
 
16
- private
17
+ protected
17
18
 
18
19
  def list_fields
19
20
  default_fields - %w{attachments}
@@ -30,9 +31,10 @@ module Brightcontent
30
31
  end
31
32
  helper_method :default_fields
32
33
 
33
- def resource_params
34
- params.require(resource_instance_name).permit!
34
+ def parent
35
+ super if parent?
35
36
  end
37
+ helper_method :parent
36
38
 
37
39
  end
38
40
  end
@@ -5,13 +5,15 @@ module Brightcontent
5
5
  end
6
6
 
7
7
  def render_form_field(form, field)
8
- render_if_exists("form_field_#{field}", form: form, item: form.object) || form.input(field.to_sym)
8
+ render_if_exists("form_field_#{field}", form: form, item: form.object) ||
9
+ render_if_exists("brightcontent/fields/#{field_type(form, field)}", form: form, item: form.object, field: field) ||
10
+ form.input(field.to_sym)
9
11
  end
10
12
 
11
13
  def link_for_scope(scope)
12
14
  case scope[:type]
13
15
  when :boolean
14
- polymorphic_url(resource_class, scope[:as] => true)
16
+ polymorphic_url([parent, resource_class], scope[:as] => true)
15
17
  end
16
18
  end
17
19
 
@@ -22,5 +24,10 @@ module Brightcontent
22
24
  rescue ActionView::MissingTemplate
23
25
  nil
24
26
  end
27
+
28
+ def field_type(form, field)
29
+ column = form.send(:find_attribute_column, field)
30
+ form.send(:default_input_type, field, column, {})
31
+ end
25
32
  end
26
33
  end
@@ -1,3 +1,3 @@
1
- <% resource_paths.each do |resource_path| %>
2
- <li><%= link_to resource_path.titleize, root_path + resource_path %></li>
1
+ <% user_resources.each do |resource| %>
2
+ <li><%= link_to resource.klass.model_name.human.pluralize, root_path + resource.path %></li>
3
3
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% flash.each do |key,value| %>
2
- <div class="flash <%= key.to_s%>">
2
+ <div class="alert alert-<%= key.to_s%>">
3
3
  <%= value %>
4
4
  </div>
5
5
  <% end %>
@@ -1,10 +1,17 @@
1
- <%= simple_form_for resource do |form| %>
1
+ <%= simple_form_for [parent, resource] do |form| -%>
2
2
  <%= form.error_notification %>
3
3
 
4
4
  <div class="form-inputs">
5
- <% form_fields.each do |form_field| %>
6
- <%= render_form_field(form, form_field) %>
7
- <% end %>
5
+ <% form_fields.each do |form_field| -%>
6
+ <%= render_form_field(form, form_field) -%>
7
+ <% end -%>
8
8
  </div>
9
+
9
10
  <%= form.button :submit, class: "btn btn-primary" %>
10
- <% end %>
11
+ <%= form.button :submit, "Save and continue", :name => "commit_and_continue" %>
12
+
13
+ <% unless resource.new_record? -%>
14
+ <%= link_to "Delete", [parent, resource], :class => "btn btn-danger delete", :method => :delete, :data => { :confirm => 'Are you sure?' } %>
15
+ <% end -%>
16
+
17
+ <% end -%>
@@ -1,2 +1,2 @@
1
- <%= link_to "Edit", polymorphic_url(item, action: :edit), class: "btn btn-mini btn-primary" %>
2
- <%= link_to "Delete", polymorphic_url(item), class: "btn btn-mini", confirm: 'Are you sure?', method: :delete %>
1
+ <%= link_to "Edit", [:edit, parent, item], class: "btn btn-mini btn-primary" %>
2
+ <%= link_to "Delete", [parent, item], class: "btn btn-mini", confirm: 'Are you sure?', method: :delete %>
@@ -1,3 +1,3 @@
1
- <h1>Edit <%= resource_instance_name.to_s %></h1>
1
+ <h1>Edit <%= resource_class.model_name.human %></h1>
2
2
 
3
3
  <%= render "form" %>
@@ -1,4 +1,4 @@
1
- <%= CSV.generate(:col_sep => ";") do |csv| %>
1
+ <%== CSV.generate(:col_sep => ";", :quote_char => '"') do |csv| %>
2
2
  <% csv << default_fields %>
3
3
  <% collection.each do |item| %>
4
4
  <% csv << default_fields.map { |field| item.send(field) } %>
@@ -1,7 +1,7 @@
1
1
  <div id="overview">
2
2
 
3
- <%= link_to "Create new #{resource_instance_name.to_s.humanize}", polymorphic_url(resource_class, action: :new), class: "btn btn-primary btn-right" %>
4
- <h1><%= resource_collection_name.to_s.humanize %></h1>
3
+ <%= link_to "Create new #{resource_instance_name.to_s.humanize}", polymorphic_url([parent, resource_class], action: :new), class: "btn btn-primary btn-right" %>
4
+ <h1><%= resource_class.model_name.human.pluralize %></h1>
5
5
 
6
6
  <%= render "scope_filters" if scopes_configuration %>
7
7
  <%= render "index_top" %>
@@ -0,0 +1,6 @@
1
+ <% if item.send(field).present? %>
2
+ <div class="controls file-preview">
3
+ <%= image_tag item.send(field).url(item.send(field).styles.keys.first) %>
4
+ </div>
5
+ <% end %>
6
+ <%= form.input field %>
@@ -15,9 +15,9 @@ Gem::Specification.new do |s|
15
15
  s.test_files = `git ls-files -- spec/*`.split("\n")
16
16
  s.require_paths = ["lib"]
17
17
 
18
- s.add_dependency "rails", "~> 3.2.9"
18
+ s.add_dependency "rails", "~> 3.2.13"
19
19
  s.add_dependency "jquery-rails"
20
- s.add_dependency "bcrypt-ruby"
20
+ s.add_dependency "bcrypt-ruby", "3.0.0"
21
21
  s.add_dependency "inherited_resources"
22
22
  s.add_dependency "has_scope"
23
23
  s.add_dependency "simple_form"
@@ -0,0 +1,10 @@
1
+ en:
2
+ flash:
3
+ actions:
4
+ create:
5
+ notice: '%{resource_name} was successfully created.'
6
+ update:
7
+ notice: '%{resource_name} was successfully updated.'
8
+ destroy:
9
+ notice: '%{resource_name} was successfully destroyed.'
10
+ alert: '%{resource_name} could not be destroyed.'
@@ -0,0 +1,10 @@
1
+ nl:
2
+ flash:
3
+ actions:
4
+ create:
5
+ notice: '%{resource_name} was successfully created.'
6
+ update:
7
+ notice: '%{resource_name} was successfully updated.'
8
+ destroy:
9
+ notice: '%{resource_name} was successfully destroyed.'
10
+ alert: '%{resource_name} could not be destroyed.'
@@ -5,15 +5,23 @@ module Brightcontent
5
5
  end
6
6
 
7
7
  def create
8
- create! { polymorphic_url(resource_class) }
8
+ if params["commit_and_continue"].present?
9
+ create! { [parent, resource] }
10
+ else
11
+ create! { [parent, resource_class] }
12
+ end
9
13
  end
10
14
 
11
15
  def update
12
- update! { polymorphic_url(resource_class) }
16
+ if params["commit_and_continue"].present?
17
+ update! { [parent, resource] }
18
+ else
19
+ update! { [parent, resource_class] }
20
+ end
13
21
  end
14
22
 
15
23
  def destroy
16
- destroy! { polymorphic_url(resource_class) }
24
+ destroy! { [parent, resource_class] }
17
25
  end
18
26
  end
19
27
  end
@@ -3,31 +3,45 @@ require 'active_support/inflector'
3
3
  module Brightcontent
4
4
  class RoutesParser
5
5
 
6
- def self.parse(routes_hash=nil, engine_resources=nil)
7
- new(routes_hash, engine_resources).user_resource
8
- end
9
-
10
6
  def initialize(routes_hash=nil, engine_resources=nil)
11
7
  @routes_hash = routes_hash
12
8
  @engine_resources = engine_resources
13
9
  end
14
10
 
15
- def user_resource
16
- resource_names - engine_resources
11
+ def resources
12
+ (resource_names - engine_resources).map do |name|
13
+ Resource.new(name)
14
+ end
15
+ end
16
+
17
+ class Resource < Struct.new(:path)
18
+ def klass
19
+ path.classify.constantize
20
+ rescue
21
+ "Brightcontent::#{path.classify}".constantize
22
+ end
17
23
  end
18
24
 
19
25
  private
20
26
 
21
27
  def resource_names
22
28
  routes_hash.map do |route|
23
- if route && route[:action] == "index"
24
- route[:controller].match(/brightcontent\/(.+)/)[1]
29
+ next unless route && route[:controller] && route[:path_spec]
30
+ name = route[:controller].match(/brightcontent\/(.+)/)[1]
31
+ if route[:action] == "index" && route[:path_spec].start_with?('/' + name)
32
+ name
25
33
  end
26
34
  end.compact.uniq
27
35
  end
28
36
 
29
37
  def routes_hash
30
- @routes_hash ||= Engine.routes.routes.map(&:defaults)
38
+ @routes_hash ||= Engine.routes.routes.map do |r|
39
+ {
40
+ controller: r.defaults[:controller],
41
+ action: r.defaults[:action],
42
+ path_spec: r.path.spec.to_s
43
+ }
44
+ end
31
45
  end
32
46
 
33
47
  def engine_resources
@@ -0,0 +1,3 @@
1
+ class Brightcontent::CommentsController < Brightcontent::BaseController
2
+ belongs_to :blog
3
+ end
@@ -1,3 +1,4 @@
1
1
  class Blog < ActiveRecord::Base
2
2
  scope :featured, where(:featured => true)
3
+ has_many :comments
3
4
  end
@@ -0,0 +1,3 @@
1
+ class Comment < ActiveRecord::Base
2
+ belongs_to :blog
3
+ end
@@ -2,6 +2,8 @@ Rails.application.routes.draw do
2
2
  resources :blogs
3
3
 
4
4
  brightcontent_resources do
5
- resources :blogs
5
+ resources :blogs do
6
+ resources :comments
7
+ end
6
8
  end
7
9
  end
@@ -0,0 +1,12 @@
1
+ class CreateComments < ActiveRecord::Migration
2
+ def change
3
+ create_table :comments do |t|
4
+ t.string :id
5
+ t.text :text
6
+ t.integer :blog_id
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :comments, :blog_id
11
+ end
12
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20121223131824) do
14
+ ActiveRecord::Schema.define(:version => 20130720211920) do
15
15
 
16
16
  create_table "blogs", :force => true do |t|
17
17
  t.string "name"
@@ -28,4 +28,13 @@ ActiveRecord::Schema.define(:version => 20121223131824) do
28
28
  t.datetime "updated_at", :null => false
29
29
  end
30
30
 
31
+ create_table "comments", :force => true do |t|
32
+ t.text "text"
33
+ t.integer "blog_id"
34
+ t.datetime "created_at", :null => false
35
+ t.datetime "updated_at", :null => false
36
+ end
37
+
38
+ add_index "comments", ["blog_id"], :name => "index_comments_on_blog_id"
39
+
31
40
  end
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ id: MyString
5
+ text: MyText
6
+ blog_id: 1
7
+
8
+ two:
9
+ id: MyString
10
+ text: MyText
11
+ blog_id: 1
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class CommentsTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -2,7 +2,7 @@ FactoryGirl.define do
2
2
  sequence :email do |n|
3
3
  "person#{n}@example.com"
4
4
  end
5
-
5
+
6
6
  factory :admin_user, class: Brightcontent::AdminUser do
7
7
  email
8
8
  password "password"
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ feature "Nested resource" do
4
+ background { sign_in }
5
+ let!(:blog) { create(:blog) }
6
+
7
+ scenario "add new nested resource item" do
8
+ create_comment "Name for Commenty"
9
+ page.should have_content "Name for Commenty"
10
+ end
11
+
12
+ scenario "edit nested resource item" do
13
+ create_comment "Name for Commenty"
14
+ update_comment "Name for Commenty", "New Commentz name"
15
+ page.should have_content "New Commentz name"
16
+ end
17
+
18
+ scenario "Removes an nested resource item" do
19
+ create_comment "Name for Commenty"
20
+ remove_comment "Name for Commenty"
21
+ page.should_not have_content "Name for Commenty"
22
+ end
23
+
24
+ def create_comment(title)
25
+ visit brightcontent.blog_comments_path(blog)
26
+ click_link "Create new Comment"
27
+ fill_in "Text", with: title
28
+ click_button "Create Comment"
29
+ end
30
+
31
+ def update_comment(title, new_title)
32
+ within_comment_item(title) { click_link "Edit" }
33
+ fill_in "Text", with: new_title
34
+ click_button "Update Comment"
35
+ end
36
+
37
+ def remove_comment(title)
38
+ within_comment_item(title) do
39
+ click_link "Delete"
40
+ end
41
+ end
42
+
43
+ def within_comment_item(title)
44
+ comment = Comment.find_by_text!(title)
45
+ within "#comment_#{comment.id}" do
46
+ yield
47
+ end
48
+ end
49
+
50
+ end
@@ -27,7 +27,7 @@ feature "Resources index" do
27
27
  end
28
28
 
29
29
  def visit_blogs_page
30
- click_link "Blogs"
30
+ click_link "Blog"
31
31
  end
32
32
 
33
33
  def page_should_have_valid_table
@@ -5,17 +5,18 @@ module Brightcontent
5
5
  let(:engine_resources) { %w{sessions admin_users} }
6
6
  let(:routes_hash) do
7
7
  [ {}, nil, {:action=>"admin"},
8
- {:action=>"index", :controller=>"brightcontent/blogs"},
9
- {:action=>"create", :controller=>"brightcontent/blogs"} ]
8
+ {:action=>"index", :controller=>"brightcontent/blogs", :path_spec => '/blogs(.:format)'},
9
+ {:action=>"create", :controller=>"brightcontent/blogs", :path_spec => '/blogs(.:format)'},
10
+ {:controller=>"brightcontent/comments", :action=>"show", :path_spec=>"/blogs/:blog_id/comments/:id(.:format)"}]
10
11
  end
11
12
 
12
- subject(:parser) { RoutesParser.parse(routes_hash, engine_resources) }
13
+ subject(:parser) { RoutesParser.new(routes_hash, engine_resources) }
13
14
 
14
- it { should eq ["blogs"] }
15
+ its(:resources) { should eq [resource("blogs")] }
15
16
 
16
17
  context "with extra resource" do
17
- before { routes_hash << {:action=>"index", :controller=>"brightcontent/articles"} }
18
- it { should eq ["blogs", "articles"] }
18
+ before { routes_hash << {:action=>"index", :controller=>"brightcontent/articles", :path_spec => '/articles' } }
19
+ its(:resources) { should eq [resource("blogs"), resource("articles")] }
19
20
  end
20
21
 
21
22
  context "with engine resources" do
@@ -24,7 +25,7 @@ module Brightcontent
24
25
  routes_hash << {:action=>"index", :controller=>"brightcontent/#{resource_name}"}
25
26
  end
26
27
  end
27
- it { should eq ["blogs"] }
28
+ its(:resources) { should eq [resource("blogs")] }
28
29
  end
29
30
 
30
31
  context "duplicate resources" do
@@ -32,7 +33,11 @@ module Brightcontent
32
33
  routes_hash << {action: "index", controller: "brightcontent/blogs" }
33
34
  end
34
35
 
35
- it { should eq ["blogs"] }
36
+ its(:resources) { should eq [resource("blogs")] }
37
+ end
38
+
39
+ def resource(path)
40
+ RoutesParser::Resource.new(path)
36
41
  end
37
42
 
38
43
  end
metadata CHANGED
@@ -1,238 +1,209 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightcontent-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.30
5
- prerelease:
4
+ version: 2.0.31
6
5
  platform: ruby
7
6
  authors:
8
7
  - Developers at Brightin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
11
+ date: 2013-07-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.9
19
+ version: 3.2.13
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 3.2.9
26
+ version: 3.2.13
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: jquery-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bcrypt-ruby
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '='
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: 3.0.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '='
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: 3.0.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: inherited_resources
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: has_scope
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: simple_form
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: will_paginate
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: bootstrap-wysihtml5-rails
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: strong_parameters
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - '>='
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :runtime
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - '>='
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: sqlite3
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - '>='
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - '>='
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: rspec-rails
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - '>='
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - '>='
188
165
  - !ruby/object:Gem::Version
189
166
  version: '0'
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: capybara
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
- - - ! '>='
171
+ - - '>='
196
172
  - !ruby/object:Gem::Version
197
173
  version: '0'
198
174
  type: :development
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
- - - ! '>='
178
+ - - '>='
204
179
  - !ruby/object:Gem::Version
205
180
  version: '0'
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: launchy
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
- - - ! '>='
185
+ - - '>='
212
186
  - !ruby/object:Gem::Version
213
187
  version: '0'
214
188
  type: :development
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
- - - ! '>='
192
+ - - '>='
220
193
  - !ruby/object:Gem::Version
221
194
  version: '0'
222
195
  - !ruby/object:Gem::Dependency
223
196
  name: factory_girl_rails
224
197
  requirement: !ruby/object:Gem::Requirement
225
- none: false
226
198
  requirements:
227
- - - ! '>='
199
+ - - '>='
228
200
  - !ruby/object:Gem::Version
229
201
  version: '0'
230
202
  type: :development
231
203
  prerelease: false
232
204
  version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
205
  requirements:
235
- - - ! '>='
206
+ - - '>='
236
207
  - !ruby/object:Gem::Version
237
208
  version: '0'
238
209
  description: Brightcontent core
@@ -276,12 +247,15 @@ files:
276
247
  - app/views/brightcontent/base/index.csv.erb
277
248
  - app/views/brightcontent/base/index.html.erb
278
249
  - app/views/brightcontent/base/new.html.erb
250
+ - app/views/brightcontent/fields/_file.html.erb
279
251
  - app/views/brightcontent/sessions/new.html.erb
280
252
  - app/views/layouts/brightcontent/application.html.erb
281
253
  - brightcontent-core.gemspec
282
254
  - config/initializers/simple_form.rb
283
255
  - config/initializers/simple_form_bootstrap.rb
284
256
  - config/initializers/will_paginate.rb
257
+ - config/locales/brightcontent.en.yml
258
+ - config/locales/brightcontent.nl.yml
285
259
  - config/routes.rb
286
260
  - db/migrate/20121206121725_create_brightcontent_admin_users.rb
287
261
  - lib/brightcontent-core.rb
@@ -292,7 +266,6 @@ files:
292
266
  - lib/brightcontent/pagination.rb
293
267
  - lib/brightcontent/rails/routes.rb
294
268
  - lib/brightcontent/routes_parser.rb
295
- - lib/brightcontent/strong_params_fix.rb
296
269
  - lib/generators/brightcontent/install_generator.rb
297
270
  - lib/generators/brightcontent/resource_generator.rb
298
271
  - lib/generators/brightcontent/templates/brightcontent_controller.rb
@@ -306,11 +279,13 @@ files:
306
279
  - spec/dummy/app/assets/stylesheets/brightcontent/custom.css
307
280
  - spec/dummy/app/controllers/application_controller.rb
308
281
  - spec/dummy/app/controllers/brightcontent/blogs_controller.rb
282
+ - spec/dummy/app/controllers/brightcontent/comments_controller.rb
309
283
  - spec/dummy/app/controllers/pages_controller.rb
310
284
  - spec/dummy/app/helpers/application_helper.rb
311
285
  - spec/dummy/app/mailers/.gitkeep
312
286
  - spec/dummy/app/models/.gitkeep
313
287
  - spec/dummy/app/models/blog.rb
288
+ - spec/dummy/app/models/comment.rb
314
289
  - spec/dummy/app/views/layouts/application.html.erb
315
290
  - spec/dummy/app/views/pages/index.html.erb
316
291
  - spec/dummy/config.ru
@@ -333,6 +308,7 @@ files:
333
308
  - spec/dummy/config/routes.rb
334
309
  - spec/dummy/db/migrate/20121206225720_create_blogs.rb
335
310
  - spec/dummy/db/migrate/20121223131824_add_featured_to_blog.rb
311
+ - spec/dummy/db/migrate/20130720211920_create_comments.rb
336
312
  - spec/dummy/db/schema.rb
337
313
  - spec/dummy/lib/assets/.gitkeep
338
314
  - spec/dummy/public/404.html
@@ -340,10 +316,13 @@ files:
340
316
  - spec/dummy/public/500.html
341
317
  - spec/dummy/public/favicon.ico
342
318
  - spec/dummy/script/rails
319
+ - spec/dummy/test/fixtures/comments.yml
320
+ - spec/dummy/test/unit/comments_test.rb
343
321
  - spec/factories.rb
344
322
  - spec/features/export_spec.rb
345
323
  - spec/features/login_spec.rb
346
324
  - spec/features/menu_spec.rb
325
+ - spec/features/nested_resource_spec.rb
347
326
  - spec/features/resources_form_spec.rb
348
327
  - spec/features/resources_index_spec.rb
349
328
  - spec/features/scope_spec.rb
@@ -353,33 +332,26 @@ files:
353
332
  - spec/support/acceptance_helper.rb
354
333
  homepage: http://brightin.nl
355
334
  licenses: []
335
+ metadata: {}
356
336
  post_install_message:
357
337
  rdoc_options: []
358
338
  require_paths:
359
339
  - lib
360
340
  required_ruby_version: !ruby/object:Gem::Requirement
361
- none: false
362
341
  requirements:
363
- - - ! '>='
342
+ - - '>='
364
343
  - !ruby/object:Gem::Version
365
344
  version: '0'
366
- segments:
367
- - 0
368
- hash: -1318734726726849324
369
345
  required_rubygems_version: !ruby/object:Gem::Requirement
370
- none: false
371
346
  requirements:
372
- - - ! '>='
347
+ - - '>='
373
348
  - !ruby/object:Gem::Version
374
349
  version: '0'
375
- segments:
376
- - 0
377
- hash: -1318734726726849324
378
350
  requirements: []
379
351
  rubyforge_project:
380
- rubygems_version: 1.8.24
352
+ rubygems_version: 2.0.2
381
353
  signing_key:
382
- specification_version: 3
354
+ specification_version: 4
383
355
  summary: Brightcontent core
384
356
  test_files:
385
357
  - spec/dummy/README.rdoc
@@ -390,11 +362,13 @@ test_files:
390
362
  - spec/dummy/app/assets/stylesheets/brightcontent/custom.css
391
363
  - spec/dummy/app/controllers/application_controller.rb
392
364
  - spec/dummy/app/controllers/brightcontent/blogs_controller.rb
365
+ - spec/dummy/app/controllers/brightcontent/comments_controller.rb
393
366
  - spec/dummy/app/controllers/pages_controller.rb
394
367
  - spec/dummy/app/helpers/application_helper.rb
395
368
  - spec/dummy/app/mailers/.gitkeep
396
369
  - spec/dummy/app/models/.gitkeep
397
370
  - spec/dummy/app/models/blog.rb
371
+ - spec/dummy/app/models/comment.rb
398
372
  - spec/dummy/app/views/layouts/application.html.erb
399
373
  - spec/dummy/app/views/pages/index.html.erb
400
374
  - spec/dummy/config.ru
@@ -417,6 +391,7 @@ test_files:
417
391
  - spec/dummy/config/routes.rb
418
392
  - spec/dummy/db/migrate/20121206225720_create_blogs.rb
419
393
  - spec/dummy/db/migrate/20121223131824_add_featured_to_blog.rb
394
+ - spec/dummy/db/migrate/20130720211920_create_comments.rb
420
395
  - spec/dummy/db/schema.rb
421
396
  - spec/dummy/lib/assets/.gitkeep
422
397
  - spec/dummy/public/404.html
@@ -424,10 +399,13 @@ test_files:
424
399
  - spec/dummy/public/500.html
425
400
  - spec/dummy/public/favicon.ico
426
401
  - spec/dummy/script/rails
402
+ - spec/dummy/test/fixtures/comments.yml
403
+ - spec/dummy/test/unit/comments_test.rb
427
404
  - spec/factories.rb
428
405
  - spec/features/export_spec.rb
429
406
  - spec/features/login_spec.rb
430
407
  - spec/features/menu_spec.rb
408
+ - spec/features/nested_resource_spec.rb
431
409
  - spec/features/resources_form_spec.rb
432
410
  - spec/features/resources_index_spec.rb
433
411
  - spec/features/scope_spec.rb
@@ -1,16 +0,0 @@
1
- module Brightcontent
2
- module StrongParamsFix
3
-
4
- def build_resource
5
- get_resource_ivar || set_resource_ivar(end_of_association_chain.send(method_for_build, params_for_build))
6
- end
7
-
8
- def params_for_build
9
- request.get? ? {} : resource_params
10
- end
11
-
12
- def update_resource(object, attributes)
13
- object.update_attributes(attributes)
14
- end
15
- end
16
- end