nocms-blocks 1.0.0

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 (87) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +8 -0
  3. data/LICENSE +674 -0
  4. data/README.md +233 -0
  5. data/Rakefile +22 -0
  6. data/app/assets/javascripts/no_cms/blocks/application.js +13 -0
  7. data/app/assets/stylesheets/no_cms/blocks/application.css +13 -0
  8. data/app/controllers/no_cms/blocks/application_controller.rb +4 -0
  9. data/app/decorators/models/no_cms/blocks/block_decorator.rb +3 -0
  10. data/app/helpers/no_cms/blocks/application_helper.rb +4 -0
  11. data/app/helpers/no_cms/blocks/blocks_helper.rb +28 -0
  12. data/app/models/no_cms/blocks/block.rb +160 -0
  13. data/app/models/no_cms/blocks/concerns/translation_scopes.rb +16 -0
  14. data/app/views/layouts/no_cms/blocks/application.html.erb +14 -0
  15. data/app/views/no_cms/admin/blocks/blocks/_default.html.erb +9 -0
  16. data/app/views/no_cms/admin/blocks/blocks/_form.html.erb +25 -0
  17. data/app/views/no_cms/admin/blocks/blocks/_index.html.erb +15 -0
  18. data/app/views/no_cms/admin/blocks/blocks/_nested_index.html.erb +17 -0
  19. data/app/views/no_cms/blocks/blocks/_default.html.erb +8 -0
  20. data/config/locales/en.yml +15 -0
  21. data/config/routes.rb +2 -0
  22. data/db/migrate/20140405135410_create_no_cms_blocks_blocks.rb +21 -0
  23. data/db/migrate/20140405150944_add_awesome_nested_set_to_no_cms_blocks.rb +8 -0
  24. data/db/migrate/20140618150651_add_position_to_no_cms_blocks_block.rb +5 -0
  25. data/lib/generators/nocms/blocks_generator.rb +15 -0
  26. data/lib/generators/nocms/templates/config/initializers/nocms/blocks.rb +43 -0
  27. data/lib/no_cms/blocks/configuration.rb +20 -0
  28. data/lib/no_cms/blocks/engine.rb +17 -0
  29. data/lib/no_cms/blocks/version.rb +5 -0
  30. data/lib/nocms-blocks.rb +7 -0
  31. data/lib/tasks/no_cms/blocks.rake +4 -0
  32. data/spec/dummy/README.rdoc +28 -0
  33. data/spec/dummy/Rakefile +6 -0
  34. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  35. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  36. data/spec/dummy/app/controllers/application_controller.rb +8 -0
  37. data/spec/dummy/app/controllers/home_controller.rb +3 -0
  38. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  39. data/spec/dummy/app/models/test_image.rb +5 -0
  40. data/spec/dummy/app/uploaders/logo_uploader.rb +51 -0
  41. data/spec/dummy/app/views/home/show.html.erb +3 -0
  42. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  43. data/spec/dummy/app/views/no_cms/blocks/blocks/_logo_caption.html.erb +5 -0
  44. data/spec/dummy/app/views/no_cms/blocks/blocks/_title_3_columns.html.erb +6 -0
  45. data/spec/dummy/bin/bundle +3 -0
  46. data/spec/dummy/bin/rails +4 -0
  47. data/spec/dummy/bin/rake +4 -0
  48. data/spec/dummy/config.ru +4 -0
  49. data/spec/dummy/config/application.rb +22 -0
  50. data/spec/dummy/config/boot.rb +5 -0
  51. data/spec/dummy/config/database.yml +25 -0
  52. data/spec/dummy/config/environment.rb +5 -0
  53. data/spec/dummy/config/environments/development.rb +29 -0
  54. data/spec/dummy/config/environments/production.rb +80 -0
  55. data/spec/dummy/config/environments/test.rb +38 -0
  56. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  57. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  58. data/spec/dummy/config/initializers/inflections.rb +16 -0
  59. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  60. data/spec/dummy/config/initializers/nocms/blocks.rb +43 -0
  61. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  62. data/spec/dummy/config/initializers/session_store.rb +3 -0
  63. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  64. data/spec/dummy/config/locales/en.yml +23 -0
  65. data/spec/dummy/config/routes.rb +5 -0
  66. data/spec/dummy/db/development.sqlite3 +0 -0
  67. data/spec/dummy/db/migrate/20140304094052_create_test_images.rb +9 -0
  68. data/spec/dummy/db/schema.rb +43 -0
  69. data/spec/dummy/db/test.sqlite3 +0 -0
  70. data/spec/dummy/log/development.log +40 -0
  71. data/spec/dummy/log/test.log +33500 -0
  72. data/spec/dummy/public/404.html +58 -0
  73. data/spec/dummy/public/422.html +58 -0
  74. data/spec/dummy/public/500.html +57 -0
  75. data/spec/dummy/public/favicon.ico +0 -0
  76. data/spec/dummy/public/uploads/test_image/logo/1/logo.png +0 -0
  77. data/spec/dummy/public/uploads/test_image/logo/1/logo2.png +0 -0
  78. data/spec/factories/no_cms/blocks/block.rb +8 -0
  79. data/spec/factories/test_image.rb +12 -0
  80. data/spec/fixtures/images/logo.png +0 -0
  81. data/spec/fixtures/images/logo2.png +0 -0
  82. data/spec/models/no_cms/blocks/block_spec.rb +200 -0
  83. data/spec/requests/no_cms/blocks/blocks_spec.rb +95 -0
  84. data/spec/spec_helper.rb +70 -0
  85. data/spec/support/concerns/model_with_has_many_relationship.rb +39 -0
  86. data/spec/support/concerns/model_with_required_attributes.rb +21 -0
  87. metadata +236 -0
@@ -0,0 +1,70 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'capybara/rspec'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc, in
8
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
9
+ # run as spec files by default. This means that files in spec/support that end
10
+ # in _spec.rb will both be required and run as specs, causing the specs to be
11
+ # run twice. It is recommended that you do not name files matching this glob to
12
+ # end with _spec.rb. You can configure this pattern with with the --pattern
13
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
14
+ Dir[Rails.root.join("../support/**/*.rb")].each { |f| require f }
15
+
16
+ # Checks for pending migrations before tests are run.
17
+ # If you are not using ActiveRecord, you can remove this line.
18
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
19
+
20
+ RSpec.configure do |config|
21
+ # ## Mock Framework
22
+ #
23
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
24
+ #
25
+ # config.mock_with :mocha
26
+ # config.mock_with :flexmock
27
+ # config.mock_with :rr
28
+
29
+ # Avoid repeating FactoryGirl
30
+ config.include FactoryGirl::Syntax::Methods
31
+
32
+ # Capybara DSL only in request specs
33
+ config.include Capybara::DSL
34
+
35
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
36
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
37
+
38
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
39
+ # examples within a transaction, remove the following line or assign false
40
+ # instead of true.
41
+ config.use_transactional_fixtures = true
42
+
43
+ # If true, the base class of anonymous controllers will be inferred
44
+ # automatically. This will be the default behavior in future versions of
45
+ # rspec-rails.
46
+ config.infer_base_class_for_anonymous_controllers = false
47
+
48
+ config.around(:each, :caching) do |example|
49
+
50
+ caching = ActionController::Base.perform_caching
51
+ blocks_caching = NoCms::Blocks.cache_enabled
52
+ ActionController::Base.perform_caching = example.metadata[:caching]
53
+ NoCms::Blocks.cache_enabled = example.metadata[:caching]
54
+
55
+ example.run
56
+
57
+ Rails.cache.clear
58
+ ActionController::Base.perform_caching = caching
59
+ NoCms::Blocks.cache_enabled = blocks_caching
60
+
61
+ end
62
+
63
+ # Run specs in random order to surface order dependencies. If you find an
64
+ # order dependency and want to debug it, you can fix the order by providing
65
+ # the seed, which is printed after each run.
66
+ # --seed 1234
67
+ config.order = "random"
68
+ end
69
+
70
+ FactoryGirl.reload
@@ -0,0 +1,39 @@
1
+ shared_examples_for "model with has many relationship" do |model_name, related_model_factory, has_many_relationship, belongs_to_relationship|
2
+
3
+ context "when creating various #{has_many_relationship}" do
4
+
5
+ let(:model_object) { create model_name }
6
+ let(:related_object_1) { create related_model_factory, belongs_to_relationship => model_object }
7
+ let(:related_object_2) { create related_model_factory, belongs_to_relationship => model_object }
8
+
9
+ before do
10
+ related_object_1 && related_object_2
11
+ end
12
+
13
+ subject { model_object }
14
+
15
+ it("should relate to all of its #{has_many_relationship}") { expect(subject.send(has_many_relationship.to_sym)).to match_array [related_object_1, related_object_2] }
16
+
17
+ context "related #{has_many_relationship.to_s.singularize}" do
18
+
19
+ subject { related_object_1 }
20
+
21
+ it("should relate to the original #{belongs_to_relationship}") {
22
+ expect(subject.send(belongs_to_relationship.to_sym)).to eq model_object
23
+ }
24
+
25
+ end
26
+
27
+ context "related #{has_many_relationship.to_s.singularize}" do
28
+
29
+ subject { related_object_2 }
30
+
31
+ it("should relate to the original #{belongs_to_relationship}") {
32
+ expect(subject.send(belongs_to_relationship.to_sym)).to eq model_object
33
+ }
34
+
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,21 @@
1
+ shared_examples_for "model with required attributes" do |model_name, required_attribute_names|
2
+
3
+ context "validations" do
4
+
5
+ # we go through the required attributes and for each one we create a context where it's set to nil and we check the object is not valid and there's an error on the attributes
6
+ required_attribute_names.each do |attribute_name|
7
+
8
+ context "with empty #{attribute_name}" do
9
+
10
+ let(:model_object) { build model_name, attribute_name => nil }
11
+ before { model_object.valid? }
12
+ subject { model_object }
13
+
14
+ it { should_not be_valid }
15
+ it { expect(subject.errors[attribute_name]).to include I18n.t('errors.messages.blank') }
16
+ end
17
+
18
+ end
19
+ end
20
+
21
+ end
metadata ADDED
@@ -0,0 +1,236 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nocms-blocks
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rodrigo Garcia Suarez
8
+ - Fernando Fdz. Zapico
9
+ - Luis Mendo
10
+ - Victor Ortiz
11
+ - David J. Brenes
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2015-06-30 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rails
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: '4.0'
24
+ - - "<="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.3
27
+ type: :runtime
28
+ prerelease: false
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ - - "<="
35
+ - !ruby/object:Gem::Version
36
+ version: 4.2.3
37
+ - !ruby/object:Gem::Dependency
38
+ name: awesome_nested_set
39
+ requirement: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 3.0.0.rc.6
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.0.0.rc.6
51
+ - !ruby/object:Gem::Dependency
52
+ name: sqlite3
53
+ requirement: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ description: This engine allow adding content blocks to other AR model with very few
66
+ dependencies.
67
+ email:
68
+ - gems@simplelogica.net
69
+ executables: []
70
+ extensions: []
71
+ extra_rdoc_files: []
72
+ files:
73
+ - CHANGELOG
74
+ - LICENSE
75
+ - README.md
76
+ - Rakefile
77
+ - app/assets/javascripts/no_cms/blocks/application.js
78
+ - app/assets/stylesheets/no_cms/blocks/application.css
79
+ - app/controllers/no_cms/blocks/application_controller.rb
80
+ - app/decorators/models/no_cms/blocks/block_decorator.rb
81
+ - app/helpers/no_cms/blocks/application_helper.rb
82
+ - app/helpers/no_cms/blocks/blocks_helper.rb
83
+ - app/models/no_cms/blocks/block.rb
84
+ - app/models/no_cms/blocks/concerns/translation_scopes.rb
85
+ - app/views/layouts/no_cms/blocks/application.html.erb
86
+ - app/views/no_cms/admin/blocks/blocks/_default.html.erb
87
+ - app/views/no_cms/admin/blocks/blocks/_form.html.erb
88
+ - app/views/no_cms/admin/blocks/blocks/_index.html.erb
89
+ - app/views/no_cms/admin/blocks/blocks/_nested_index.html.erb
90
+ - app/views/no_cms/blocks/blocks/_default.html.erb
91
+ - config/locales/en.yml
92
+ - config/routes.rb
93
+ - db/migrate/20140405135410_create_no_cms_blocks_blocks.rb
94
+ - db/migrate/20140405150944_add_awesome_nested_set_to_no_cms_blocks.rb
95
+ - db/migrate/20140618150651_add_position_to_no_cms_blocks_block.rb
96
+ - lib/generators/nocms/blocks_generator.rb
97
+ - lib/generators/nocms/templates/config/initializers/nocms/blocks.rb
98
+ - lib/no_cms/blocks/configuration.rb
99
+ - lib/no_cms/blocks/engine.rb
100
+ - lib/no_cms/blocks/version.rb
101
+ - lib/nocms-blocks.rb
102
+ - lib/tasks/no_cms/blocks.rake
103
+ - spec/dummy/README.rdoc
104
+ - spec/dummy/Rakefile
105
+ - spec/dummy/app/assets/javascripts/application.js
106
+ - spec/dummy/app/assets/stylesheets/application.css
107
+ - spec/dummy/app/controllers/application_controller.rb
108
+ - spec/dummy/app/controllers/home_controller.rb
109
+ - spec/dummy/app/helpers/application_helper.rb
110
+ - spec/dummy/app/models/test_image.rb
111
+ - spec/dummy/app/uploaders/logo_uploader.rb
112
+ - spec/dummy/app/views/home/show.html.erb
113
+ - spec/dummy/app/views/layouts/application.html.erb
114
+ - spec/dummy/app/views/no_cms/blocks/blocks/_logo_caption.html.erb
115
+ - spec/dummy/app/views/no_cms/blocks/blocks/_title_3_columns.html.erb
116
+ - spec/dummy/bin/bundle
117
+ - spec/dummy/bin/rails
118
+ - spec/dummy/bin/rake
119
+ - spec/dummy/config.ru
120
+ - spec/dummy/config/application.rb
121
+ - spec/dummy/config/boot.rb
122
+ - spec/dummy/config/database.yml
123
+ - spec/dummy/config/environment.rb
124
+ - spec/dummy/config/environments/development.rb
125
+ - spec/dummy/config/environments/production.rb
126
+ - spec/dummy/config/environments/test.rb
127
+ - spec/dummy/config/initializers/backtrace_silencers.rb
128
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
129
+ - spec/dummy/config/initializers/inflections.rb
130
+ - spec/dummy/config/initializers/mime_types.rb
131
+ - spec/dummy/config/initializers/nocms/blocks.rb
132
+ - spec/dummy/config/initializers/secret_token.rb
133
+ - spec/dummy/config/initializers/session_store.rb
134
+ - spec/dummy/config/initializers/wrap_parameters.rb
135
+ - spec/dummy/config/locales/en.yml
136
+ - spec/dummy/config/routes.rb
137
+ - spec/dummy/db/development.sqlite3
138
+ - spec/dummy/db/migrate/20140304094052_create_test_images.rb
139
+ - spec/dummy/db/schema.rb
140
+ - spec/dummy/db/test.sqlite3
141
+ - spec/dummy/log/development.log
142
+ - spec/dummy/log/test.log
143
+ - spec/dummy/public/404.html
144
+ - spec/dummy/public/422.html
145
+ - spec/dummy/public/500.html
146
+ - spec/dummy/public/favicon.ico
147
+ - spec/dummy/public/uploads/test_image/logo/1/logo.png
148
+ - spec/dummy/public/uploads/test_image/logo/1/logo2.png
149
+ - spec/factories/no_cms/blocks/block.rb
150
+ - spec/factories/test_image.rb
151
+ - spec/fixtures/images/logo.png
152
+ - spec/fixtures/images/logo2.png
153
+ - spec/models/no_cms/blocks/block_spec.rb
154
+ - spec/requests/no_cms/blocks/blocks_spec.rb
155
+ - spec/spec_helper.rb
156
+ - spec/support/concerns/model_with_has_many_relationship.rb
157
+ - spec/support/concerns/model_with_required_attributes.rb
158
+ homepage: https://github.com/simplelogica/nocms-blocks
159
+ licenses: []
160
+ metadata: {}
161
+ post_install_message:
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubyforge_project:
177
+ rubygems_version: 2.2.2
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Engine of configurable content blocks CMS agnostic (NoCMS).
181
+ test_files:
182
+ - spec/models/no_cms/blocks/block_spec.rb
183
+ - spec/fixtures/images/logo2.png
184
+ - spec/fixtures/images/logo.png
185
+ - spec/support/concerns/model_with_required_attributes.rb
186
+ - spec/support/concerns/model_with_has_many_relationship.rb
187
+ - spec/spec_helper.rb
188
+ - spec/requests/no_cms/blocks/blocks_spec.rb
189
+ - spec/dummy/public/favicon.ico
190
+ - spec/dummy/public/uploads/test_image/logo/1/logo2.png
191
+ - spec/dummy/public/uploads/test_image/logo/1/logo.png
192
+ - spec/dummy/public/500.html
193
+ - spec/dummy/public/422.html
194
+ - spec/dummy/public/404.html
195
+ - spec/dummy/bin/bundle
196
+ - spec/dummy/bin/rails
197
+ - spec/dummy/bin/rake
198
+ - spec/dummy/README.rdoc
199
+ - spec/dummy/config/database.yml
200
+ - spec/dummy/config/routes.rb
201
+ - spec/dummy/config/locales/en.yml
202
+ - spec/dummy/config/application.rb
203
+ - spec/dummy/config/boot.rb
204
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
205
+ - spec/dummy/config/initializers/wrap_parameters.rb
206
+ - spec/dummy/config/initializers/mime_types.rb
207
+ - spec/dummy/config/initializers/nocms/blocks.rb
208
+ - spec/dummy/config/initializers/secret_token.rb
209
+ - spec/dummy/config/initializers/inflections.rb
210
+ - spec/dummy/config/initializers/backtrace_silencers.rb
211
+ - spec/dummy/config/initializers/session_store.rb
212
+ - spec/dummy/config/environment.rb
213
+ - spec/dummy/config/environments/production.rb
214
+ - spec/dummy/config/environments/development.rb
215
+ - spec/dummy/config/environments/test.rb
216
+ - spec/dummy/Rakefile
217
+ - spec/dummy/app/models/test_image.rb
218
+ - spec/dummy/app/assets/stylesheets/application.css
219
+ - spec/dummy/app/assets/javascripts/application.js
220
+ - spec/dummy/app/uploaders/logo_uploader.rb
221
+ - spec/dummy/app/helpers/application_helper.rb
222
+ - spec/dummy/app/controllers/application_controller.rb
223
+ - spec/dummy/app/controllers/home_controller.rb
224
+ - spec/dummy/app/views/home/show.html.erb
225
+ - spec/dummy/app/views/no_cms/blocks/blocks/_title_3_columns.html.erb
226
+ - spec/dummy/app/views/no_cms/blocks/blocks/_logo_caption.html.erb
227
+ - spec/dummy/app/views/layouts/application.html.erb
228
+ - spec/dummy/config.ru
229
+ - spec/dummy/log/test.log
230
+ - spec/dummy/log/development.log
231
+ - spec/dummy/db/schema.rb
232
+ - spec/dummy/db/test.sqlite3
233
+ - spec/dummy/db/development.sqlite3
234
+ - spec/dummy/db/migrate/20140304094052_create_test_images.rb
235
+ - spec/factories/test_image.rb
236
+ - spec/factories/no_cms/blocks/block.rb