dry_crud 2.1.1 → 2.1.2

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 (37) hide show
  1. checksums.yaml +9 -9
  2. data/VERSION +1 -1
  3. data/app/assets/stylesheets/sample.scss +1 -1
  4. data/app/controllers/crud_controller.rb +1 -1
  5. data/app/controllers/dry_crud/generic_model.rb +45 -45
  6. data/app/controllers/dry_crud/nestable.rb +1 -1
  7. data/app/controllers/dry_crud/render_callbacks.rb +2 -0
  8. data/app/controllers/dry_crud/responder.rb +3 -0
  9. data/app/controllers/list_controller.rb +1 -1
  10. data/app/helpers/dry_crud/form/builder.rb +286 -261
  11. data/app/helpers/dry_crud/form/control.rb +156 -153
  12. data/app/helpers/dry_crud/table/actions.rb +69 -67
  13. data/app/helpers/dry_crud/table/builder.rb +96 -95
  14. data/app/helpers/dry_crud/table/col.rb +17 -16
  15. data/app/helpers/dry_crud/table/sorting.rb +48 -46
  16. data/app/helpers/format_helper.rb +2 -2
  17. data/app/helpers/table_helper.rb +2 -2
  18. data/lib/generators/dry_crud/file_generator.rb +2 -2
  19. data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +4 -6
  20. data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/form/builder_spec.rb +11 -11
  21. data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +21 -21
  22. data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +21 -17
  23. data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +8 -8
  24. data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +11 -1
  25. data/lib/generators/dry_crud/templates/test/controllers/crud_test_models_controller_test.rb +6 -6
  26. data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +1 -0
  27. data/lib/generators/dry_crud/templates/test/helpers/dry_crud/form/builder_test.rb +250 -245
  28. data/lib/generators/dry_crud/templates/test/helpers/dry_crud/table/builder_test.rb +141 -128
  29. data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +54 -54
  30. data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +4 -4
  31. data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +1 -1
  32. data/lib/generators/dry_crud/templates/test/support/crud_controller_test_helper.rb +3 -2
  33. data/lib/generators/dry_crud/templates/test/support/crud_test_helper.rb +8 -8
  34. data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +0 -2
  35. data/lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb +7 -7
  36. data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +3 -3
  37. metadata +6 -6
@@ -28,7 +28,7 @@ class TableHelperTest < ActionView::TestCase
28
28
  test 'empty table should render message' do
29
29
  result = plain_table_or_message([]) {}
30
30
  assert result.html_safe?
31
- assert_match /\<div class=["']table["']\>.*\<\/div\>/, result
31
+ assert_match(/\<div class=["']table["']\>.*\<\/div\>/, result)
32
32
  end
33
33
 
34
34
  test 'non empty table should render table' do
@@ -151,8 +151,9 @@ module CrudControllerTestHelper
151
151
  def assert_attrs_equal(attrs) # :nodoc:
152
152
  attrs.each do |key, value|
153
153
  actual = entry.send(key)
154
- assert_equal value, actual,
155
- "#{key} is expected to be <#{value.inspect}>, " +
154
+ assert_equal value,
155
+ actual,
156
+ "#{key} is expected to be <#{value.inspect}>, " \
156
157
  "got <#{actual.inspect}>"
157
158
  end
158
159
  end
@@ -33,7 +33,7 @@ module CrudTestHelper
33
33
  entry
34
34
  end
35
35
 
36
- def sortable?(attr)
36
+ def sortable?(_attr)
37
37
  true
38
38
  end
39
39
 
@@ -81,8 +81,8 @@ module CrudTestHelper
81
81
 
82
82
  def create_other_crud_test_models(c)
83
83
  c.create_table :other_crud_test_models, force: true do |t|
84
- t.string :name, null: false, limit: 50
85
- t.integer :more_id
84
+ t.string :name, null: false, limit: 50
85
+ t.integer :more_id
86
86
  end
87
87
  end
88
88
 
@@ -128,11 +128,11 @@ module CrudTestHelper
128
128
  # test:unit uses instance variable, rspec the method
129
129
  controller = @controller || @_controller || controller
130
130
  @routes = ActionDispatch::Routing::RouteSet.new
131
- _routes = @routes
131
+ routes = @routes
132
132
 
133
- controller.singleton_class.send(:include, _routes.url_helpers)
133
+ controller.singleton_class.send(:include, routes.url_helpers)
134
134
  controller.view_context_class = Class.new(controller.view_context_class) do
135
- include _routes.url_helpers
135
+ include routes.url_helpers
136
136
  end
137
137
 
138
138
  @routes.draw { resources :crud_test_models }
@@ -148,8 +148,8 @@ module CrudTestHelper
148
148
  birthdate: "#{1900 + 10 * index}-#{index}-#{index}",
149
149
  # store entire date to avoid time zone issues
150
150
  gets_up_at: Time.zone.local(2000, 1, 1, index, index),
151
- last_seen: "#{2000 + 10 * index}-#{index}-#{index} " +
152
- "1#{index}:2#{index}",
151
+ last_seen: "#{2000 + 10 * index}-#{index}-#{index} " \
152
+ "1#{index}:2#{index}",
153
153
  human: index.even?,
154
154
  remarks: "#{c} #{str(index + 1)} #{str(index + 2)}\n" *
155
155
  (index % 3 + 1))
@@ -46,5 +46,3 @@ class OtherCrudTestModel < ActiveRecord::Base #:nodoc:
46
46
  name
47
47
  end
48
48
  end
49
-
50
-
@@ -31,7 +31,7 @@ class CrudTestModelsController < CrudController #:nodoc:
31
31
 
32
32
  def index
33
33
  super do |format|
34
- format.js { render text: 'index js'}
34
+ format.js { render text: 'index js' }
35
35
  end
36
36
  end
37
37
 
@@ -42,7 +42,7 @@ class CrudTestModelsController < CrudController #:nodoc:
42
42
  end
43
43
 
44
44
  def create
45
- super do |format|
45
+ super do |_format|
46
46
  flash[:notice] = 'model got created' if entry.persisted?
47
47
  end
48
48
  end
@@ -89,20 +89,20 @@ class CrudTestModelsController < CrudController #:nodoc:
89
89
 
90
90
  # create callback methods that record the before/after callbacks
91
91
  [:create, :update, :save, :destroy].each do |a|
92
- callback = "before_#{a.to_s}"
92
+ callback = "before_#{a}"
93
93
  send(callback.to_sym, :"#{HANDLE_PREFIX}#{callback}")
94
- callback = "after_#{a.to_s}"
94
+ callback = "after_#{a}"
95
95
  send(callback.to_sym, :"#{HANDLE_PREFIX}#{callback}")
96
96
  end
97
97
 
98
98
  # create callback methods that record the before_render callbacks
99
99
  [:index, :show, :new, :edit, :form].each do |a|
100
- callback = "before_render_#{a.to_s}"
100
+ callback = "before_render_#{a}"
101
101
  send(callback.to_sym, :"#{HANDLE_PREFIX}#{callback}")
102
102
  end
103
103
 
104
104
  # handle the called callbacks
105
- def method_missing(sym, *args)
105
+ def method_missing(sym, *_args)
106
106
  if sym.to_s.starts_with?(HANDLE_PREFIX)
107
107
  called_callback(sym.to_s[HANDLE_PREFIX.size..-1].to_sym)
108
108
  end
@@ -114,4 +114,4 @@ class CrudTestModelsController < CrudController #:nodoc:
114
114
  @called_callbacks << callback
115
115
  end
116
116
 
117
- end
117
+ end
@@ -15,7 +15,7 @@ module CustomAssertions
15
15
  def assert_count(expected, regexp, string, msg = '')
16
16
  actual = string.scan(regexp).size
17
17
  msg = message(msg) do
18
- "Expected #{mu_pp(regexp)} to occur #{expected} time(s), " +
18
+ "Expected #{mu_pp(regexp)} to occur #{expected} time(s), " \
19
19
  "but occured #{actual} time(s) in \n#{mu_pp(string)}"
20
20
  end
21
21
  assert expected == actual, msg
@@ -26,7 +26,7 @@ module CustomAssertions
26
26
  def assert_valid(record, msg = '')
27
27
  record.valid?
28
28
  msg = message(msg) do
29
- "Expected #{mu_pp(record)} to be valid, " +
29
+ "Expected #{mu_pp(record)} to be valid, " \
30
30
  "but has the following errors:\n" +
31
31
  mu_pp(record.errors.full_messages.join("\n"))
32
32
  end
@@ -73,7 +73,7 @@ module CustomAssertions
73
73
  def assert_other_attrs_have_no_errors(record, *invalid_attrs)
74
74
  record.errors.each do |a, error|
75
75
  msg = message do
76
- "Attribute #{mu_pp(a)} not declared as invalid attribute, " +
76
+ "Attribute #{mu_pp(a)} not declared as invalid attribute, " \
77
77
  "but has the following error(s):\n#{mu_pp(error)}"
78
78
  end
79
79
  assert invalid_attrs.include?(a), msg
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry_crud
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Zumkehr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -40,6 +40,9 @@ extra_rdoc_files:
40
40
  - README.rdoc
41
41
  - VERSION
42
42
  files:
43
+ - MIT-LICENSE
44
+ - README.rdoc
45
+ - VERSION
43
46
  - app/assets/images/actions/add.png
44
47
  - app/assets/images/actions/delete.png
45
48
  - app/assets/images/actions/edit.png
@@ -138,9 +141,6 @@ files:
138
141
  - lib/generators/dry_crud/templates/test/support/crud_test_model.rb
139
142
  - lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb
140
143
  - lib/generators/dry_crud/templates/test/support/custom_assertions.rb
141
- - MIT-LICENSE
142
- - README.rdoc
143
- - VERSION
144
144
  homepage: http://codez.ch/dry_crud
145
145
  licenses: []
146
146
  metadata: {}
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.0.6
168
+ rubygems_version: 2.2.2
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Generates DRY and specifically extendable CRUD controller, views and helpers