express_admin 1.4.10 → 1.4.11

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/express_admin/shared/_tables.sass +5 -0
  3. data/app/components/express_admin/smart_table.rb +1 -1
  4. data/app/components/express_admin/widget_box.rb +5 -1
  5. data/app/helpers/express_admin/admin_helper.rb +2 -2
  6. data/lib/express_admin/standard_actions.rb +54 -7
  7. data/lib/express_admin/version.rb +1 -1
  8. data/test/controllers/standard_controller_test.rb +6 -0
  9. data/test/dummy/app/models/widget.rb +2 -0
  10. data/test/dummy/db/test.sqlite3 +0 -0
  11. data/test/dummy/test/components/definition_list_test.rb +1 -1
  12. data/test/dummy/test/components/definition_table_test.rb +1 -1
  13. data/test/dummy/test/components/flash_messages_test.rb +6 -9
  14. data/test/dummy/test/components/icon_link_test.rb +1 -1
  15. data/test/dummy/test/components/icon_test.rb +1 -1
  16. data/test/dummy/test/components/module_sidebar_test.rb +16 -22
  17. data/test/dummy/test/components/smart_form_test.rb +4 -4
  18. data/test/dummy/test/components/smart_table_test.rb +6 -9
  19. data/test/dummy/test/components/widget_box_test.rb +5 -5
  20. data/test/test_helper.rb +11 -9
  21. data/vendor/gems/express_templates/Gemfile.lock +1 -1
  22. data/vendor/gems/express_templates/express_templates-0.10.0.gem +0 -0
  23. data/vendor/gems/express_templates/lib/express_templates/components/all.rb +26 -0
  24. data/vendor/gems/express_templates/lib/express_templates/components/capabilities/resourceful.rb +11 -15
  25. data/vendor/gems/express_templates/lib/express_templates/components/forms/basic_fields.rb +4 -4
  26. data/vendor/gems/express_templates/lib/express_templates/components/forms/checkbox.rb +1 -1
  27. data/vendor/gems/express_templates/lib/express_templates/components/forms/express_form.rb +6 -2
  28. data/vendor/gems/express_templates/lib/express_templates/components/forms/form_component.rb +16 -4
  29. data/vendor/gems/express_templates/lib/express_templates/components/forms/radio.rb +3 -3
  30. data/vendor/gems/express_templates/lib/express_templates/components.rb +1 -0
  31. data/vendor/gems/express_templates/lib/express_templates/version.rb +1 -1
  32. data/vendor/gems/express_templates/test/components/forms/basic_fields_test.rb +17 -9
  33. data/vendor/gems/express_templates/test/components/forms/checkbox_test.rb +13 -3
  34. data/vendor/gems/express_templates/test/components/forms/express_form_test.rb +12 -8
  35. data/vendor/gems/express_templates/test/components/forms/radio_test.rb +14 -2
  36. data/vendor/gems/express_templates/test/components/forms/select_test.rb +11 -3
  37. data/vendor/gems/express_templates/test/dummy/log/test.log +5511 -0
  38. data/vendor/gems/express_templates/test/test_helper.rb +3 -17
  39. metadata +6 -4
@@ -17,7 +17,7 @@ module ExpressTemplates
17
17
  }
18
18
 
19
19
  def use_options_from_collection_radio_buttons_helper
20
- collection_radio_buttons(resource_var, field_name.to_sym, collection_from_association,
20
+ collection_radio_buttons(resource_name, field_name.to_sym, collection_from_association,
21
21
  option_value_method, option_name_method,
22
22
  input_attributes) do |b|
23
23
  b.label(class: "radio") {
@@ -39,14 +39,14 @@ module ExpressTemplates
39
39
  when option_collection.kind_of?(Array)
40
40
  option_collection.each_with_index do |option, index|
41
41
  label(class: config[:label_wrapper_class]) {
42
- radio_button(resource_var, field_name.to_sym, option, class: 'radio')
42
+ radio_button(resource_name, field_name.to_sym, option, class: 'radio')
43
43
  current_arbre_element.add_child option
44
44
  }
45
45
  end
46
46
  when option_collection.kind_of?(Hash)
47
47
  option_collection.each_pair do |key, value|
48
48
  label(class: config[:label_wrapper_class]) {
49
- radio_button(resource_var, field_name.to_sym, key, class: 'radio')
49
+ radio_button(resource_name, field_name.to_sym, key, class: 'radio')
50
50
  current_arbre_element.add_child value
51
51
  }
52
52
  end
@@ -8,3 +8,4 @@ require 'express_templates/components/configurable'
8
8
  require 'express_templates/components/container'
9
9
  require 'express_templates/components/tree_for'
10
10
  require 'express_templates/components/forms'
11
+ require 'express_templates/components/all'
@@ -1,3 +1,3 @@
1
1
  module ExpressTemplates
2
- VERSION = "0.9.8"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -8,7 +8,15 @@ class BasicFieldsTest < ActiveSupport::TestCase
8
8
  search telephone time url week)
9
9
 
10
10
  def assigns
11
- {resource: resource}
11
+ {foo: resource}
12
+ end
13
+
14
+ def helpers
15
+ mock_action_view do
16
+ def foos_path
17
+ '/foos'
18
+ end
19
+ end
12
20
  end
13
21
 
14
22
  def field_type_map
@@ -67,7 +75,7 @@ class BasicFieldsTest < ActiveSupport::TestCase
67
75
  }
68
76
  }
69
77
  assert_match label_html, html
70
- assert_match /<textarea rows="5" class="tinymce form-field" name="foo\[bar\]" id="foo_bar"><\/textarea>/, html.gsub("\n", '')
78
+ assert_match /<textarea name="foo\[bar\]" id="foo_bar" rows="5" class="tinymce form-field"><\/textarea>/, html.gsub("\n", '')
71
79
  end
72
80
 
73
81
  test "hidden uses rails hidden_tag helper" do
@@ -87,7 +95,7 @@ class BasicFieldsTest < ActiveSupport::TestCase
87
95
  }
88
96
  }
89
97
  assert_no_match label_html, html
90
- assert_match /<input class="hidden form-field" value="ninja" type="hidden" name="foo\[bar\]" id="foo_bar"/, html
98
+ assert_match /<input type="hidden" name="foo\[bar\]" id="foo_bar" value="ninja" class="hidden form-field"/, html
91
99
  end
92
100
 
93
101
  def resource_with_errors
@@ -113,37 +121,37 @@ class BasicFieldsTest < ActiveSupport::TestCase
113
121
  end
114
122
 
115
123
  test "adds error class if there are errors on a field with no input attributes" do
116
- html_with_error = arbre(resource: resource_with_errors) {
124
+ html_with_error = arbre(foo: resource_with_errors) {
117
125
  express_form(:foo) {
118
126
  text :name
119
127
  text :body
120
128
  }
121
129
  }
122
130
  assert resource_with_errors.errors.any?
123
- assert assigns[:resource].errors.any?
131
+ assert assigns[:foo].errors.any?
124
132
  assert has_error_class_on(:name, html_with_error), "name field has no error when expected"
125
133
  refute has_error_class_on(:body, html_with_error), "body field has error class when it should not"
126
134
  end
127
135
 
128
136
  test "adds error class if there are errors on a field with no class set" do
129
- html_with_error = arbre(resource: resource_with_errors) {
137
+ html_with_error = arbre(foo: resource_with_errors) {
130
138
  express_form(:foo) {
131
139
  text :name, value: 'ninja'
132
140
  }
133
141
  }
134
142
  assert resource_with_errors.errors.any?
135
- assert assigns[:resource].errors.any?
143
+ assert assigns[:foo].errors.any?
136
144
  assert_match has_error_class, html_with_error
137
145
  end
138
146
 
139
147
  test "adds error to class if there are errors on a field with existing class" do
140
- html_with_error = arbre(resource: resource_with_errors) {
148
+ html_with_error = arbre(foo: resource_with_errors) {
141
149
  express_form(:foo) {
142
150
  text :name, value: 'ninja', class: 'slug'
143
151
  }
144
152
  }
145
153
  assert resource_with_errors.errors.any?
146
- assert assigns[:resource].errors.any?
154
+ assert assigns[:foo].errors.any?
147
155
  assert_match has_error_class, html_with_error
148
156
  end
149
157
 
@@ -1,12 +1,22 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class CheckboxTest < ActiveSupport::TestCase
4
+
4
5
  def assigns
5
- {resource: resource}
6
+ {account: resource}
7
+ end
8
+
9
+ def helpers
10
+ mock_action_view do
11
+ def accounts_path
12
+ '/accounts'
13
+ end
14
+ end
6
15
  end
7
16
 
17
+
8
18
  test "checkbox places the label before the input" do
9
- html = arbre {
19
+ html = arbre(account: resource) {
10
20
  express_form(:account) {
11
21
  checkbox :eula
12
22
  }
@@ -21,7 +31,7 @@ class CheckboxTest < ActiveSupport::TestCase
21
31
  end
22
32
 
23
33
  test "checkbox respects label_after: true " do
24
- html = arbre {
34
+ html = arbre(account: resource) {
25
35
  express_form(:account) {
26
36
  checkbox :eula, label_after: true
27
37
  }
@@ -6,24 +6,28 @@ require 'test_helper'
6
6
 
7
7
  class ExpressFormTest < ActiveSupport::TestCase
8
8
 
9
- def assigns
10
- {resource: resource}
11
- end
12
-
13
9
  def simplest_form
14
- arbre {
15
- express_form(:resource) {
10
+ arbre(foo: resource) {
11
+ express_form(:foo) {
16
12
  submit value: 'Save it!'
17
13
  }
18
14
  }
19
15
  end
20
16
 
17
+ def helpers
18
+ mock_action_view do
19
+ def foos_path
20
+ '/foos'
21
+ end
22
+ end
23
+ end
24
+
21
25
  test "simplest form renders" do
22
26
  assert simplest_form
23
27
  end
24
28
 
25
29
  test "simplest form will have the proper id" do
26
- assert_match /<form.*id="resource_1"/, simplest_form
30
+ assert_match /<form.*id="foo_1"/, simplest_form
27
31
  end
28
32
 
29
33
  test "simplest form contains form tag" do
@@ -48,7 +52,7 @@ class ExpressFormTest < ActiveSupport::TestCase
48
52
 
49
53
  test "simplest_form uses form_action for the action" do
50
54
  form_open_tag = simplest_form.match(/<form[^>]*>/)[0]
51
- assert_match 'action="/resources"', form_open_tag
55
+ assert_match 'action="/foos"', form_open_tag
52
56
  end
53
57
 
54
58
  test "express_form default method is POST" do
@@ -3,7 +3,19 @@ require 'test_helper'
3
3
  class RadioTest < ActiveSupport::TestCase
4
4
 
5
5
  def assigns
6
- {resource: resource}
6
+ {person: ::Person.new}
7
+ end
8
+
9
+ def helpers
10
+ mock_action_view do
11
+ def people_path
12
+ '/people'
13
+ end
14
+
15
+ def employees_path
16
+ '/employees'
17
+ end
18
+ end
7
19
  end
8
20
 
9
21
  test "radio requires a parent component" do
@@ -58,7 +70,7 @@ class RadioTest < ActiveSupport::TestCase
58
70
  end
59
71
 
60
72
  def radio_with_options_omitted
61
- html = arbre {
73
+ html = arbre(employee: resource) {
62
74
  express_form(:employee) {
63
75
  radio :department_id
64
76
  }
@@ -3,7 +3,15 @@ require 'ostruct'
3
3
  class SelectTest < ActiveSupport::TestCase
4
4
 
5
5
  def assigns
6
- {resource: ::Person.new}
6
+ {person: ::Person.new}
7
+ end
8
+
9
+ def helpers
10
+ mock_action_view do
11
+ def people_path
12
+ '/people'
13
+ end
14
+ end
7
15
  end
8
16
 
9
17
 
@@ -112,8 +120,8 @@ class SelectTest < ActiveSupport::TestCase
112
120
  }
113
121
  }
114
122
  assert_match 'tagging_ids', html
115
- assert_match /<option value="1">Friend<\/option>/, html
116
- assert_match /<option value="2">Enemy<\/option>/, html
123
+ assert_match /<option selected="selected" value="1">Friend<\/option>/, html
124
+ assert_match /<option selected="selected" value="2">Enemy<\/option>/, html
117
125
  assert_match /<option value="3">Frenemy<\/option>/, html
118
126
  end
119
127