express_admin 1.4.9 → 1.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d6525904c34f5ec4593ff82f6921c32c4597724
4
- data.tar.gz: 15f8843bbad74ad6596e464004067f117442fe10
3
+ metadata.gz: e25ebe07ee84728e3a8f4acca5974226f02d2f21
4
+ data.tar.gz: 4a76de8d7ac61d45004c76f75b40e4fb7ed369d3
5
5
  SHA512:
6
- metadata.gz: 4375c6e115b9e5b04d6d2c8f119f8bf050f784b04faf24918cab2b6e0d5833c901a5f45ad4493d7e5db10822dfacd93b1337e129da4079d275461a28613900a7
7
- data.tar.gz: 9ae5e0edf572509570291774144b6afd7ab131c2ae7ffdea694c86a6c6c4c73341894e1e2ce64a263ad0a003a87f67e1fb5432276c17fbc43ff6fc494e13ec4c
6
+ metadata.gz: 490d110f3e7eaff50d813d3b7b1c7248e758635b1badeef9f44211c09d3efe64a0eb99902408ab67412a086c2bc03d7b3794587474b54eb216ec61342827b420
7
+ data.tar.gz: 7ad9bbce99efb8503150a6e955d905733da5b14b30eb92a493241e3dc448e92fc3820fde08ceb470ff5a6d279cf7f75a78d2de4f622b2d0dce5b3958ed1df3c5
@@ -184,7 +184,11 @@ module ExpressAdmin
184
184
  end
185
185
 
186
186
  def build_resource(*args)
187
- self.instance_variable_set(resource_ivar, resource_class.new(*args))
187
+ if nested?
188
+ self.instance_variable_set(resource_ivar, end_of_association_chain.build(*args))
189
+ else
190
+ self.instance_variable_set(resource_ivar, resource_class.new(*args))
191
+ end
188
192
  end
189
193
 
190
194
  def load_resource
@@ -1,3 +1,3 @@
1
1
  module ExpressAdmin
2
- VERSION = "1.4.9"
2
+ VERSION = "1.4.10"
3
3
  end
@@ -1,10 +1,8 @@
1
- row {
2
- main_region {
3
- smart_table(:categories, show_on_click: true)
4
- }
5
- sidebar_region {
6
- widget_box(:category) {
7
- smart_form(:category)
8
- }
1
+ main_region {
2
+ smart_table(:categories)
3
+ }
4
+ sidebar_region {
5
+ widget_box(:category) {
6
+ smart_form(:category)
9
7
  }
10
8
  }
Binary file
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ module Admin
4
+ class CategoriesControllerTest < ActionController::TestCase
5
+ fixtures :all
6
+
7
+ test 'it should properly build and create resources' do
8
+ post :create, category: {name: 'Songs'}
9
+
10
+ category = Category.find_by_name 'Songs'
11
+ assert_redirected_to admin_category_url category
12
+
13
+ response = get :index
14
+ assert_match /Songs/, response.body
15
+ end
16
+ end
17
+ end
@@ -4,17 +4,32 @@ module Admin
4
4
  class PartsControllerTest < ActionController::TestCase
5
5
  fixtures :all
6
6
 
7
+ def setup
8
+ @toy_category = categories(:toys).to_param
9
+ @lego_widget = widgets(:one).to_param
10
+ @some_part = parts(:one).to_param
11
+ end
12
+
7
13
  test "should get show" do
8
- get :show, category_id: categories(:toys).to_param, widget_id: widgets(:one).to_param, id: parts(:one).to_param
14
+ get :show, category_id: @toy_category, widget_id: @lego_widget, id: @some_part
9
15
  assert_response :success
10
16
  end
11
17
 
12
18
  test "should display the nested index" do
13
- response = get :index, category_id: categories(:toys).to_param, widget_id: widgets(:one).to_param
19
+ response = get :index, category_id: @toy_category, widget_id: @lego_widget
14
20
  assert_response :success
15
21
  assert_match /Some part/, response.body
16
22
  refute_match /Another part/, response.body
17
23
  end
18
24
 
25
+ test "nested resources should build from parent resource" do
26
+ post :create, category_id: @toy_category, widget_id: @lego_widget, part: {name: 'Yellow'}
27
+
28
+ response = get :index, category_id: @toy_category, widget_id: @lego_widget
29
+ assert_match /Some part/, response.body
30
+ assert_match /Yellow/, response.body
31
+ refute_match /Another part/, response.body
32
+ end
33
+
19
34
  end
20
35
  end
@@ -4,17 +4,30 @@ module Admin
4
4
  class WidgetsControllerTest < ActionController::TestCase
5
5
  fixtures :all
6
6
 
7
+ def setup
8
+ @toy_category = categories(:toys).to_param
9
+ end
10
+
7
11
  test "should get show" do
8
- get :show, category_id: categories(:toys).to_param, id: widgets(:one).to_param
12
+ get :show, category_id: @toy_category, id: widgets(:one).to_param
9
13
  assert_response :success
10
14
  end
11
15
 
12
16
  test "should display the nested index" do
13
- response = get :index, category_id: categories(:toys).to_param
17
+ response = get :index, category_id: @toy_category
14
18
  assert_response :success
15
19
  assert_match /Lego/, response.body
16
20
  refute_match /Hammer/, response.body
17
21
  end
18
22
 
23
+ test "nested resources should build from parent resource" do
24
+ post :create, category_id: @toy_category, widget: {column2: 'Cars'}
25
+
26
+ response = get :index, category_id: @toy_category
27
+ assert_match /Lego/, response.body
28
+ assert_match /Cars/, response.body
29
+ refute_match /Hammer/, response.body
30
+ end
31
+
19
32
  end
20
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.9
4
+ version: 1.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Talcott Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bourbon
@@ -521,6 +521,7 @@ files:
521
521
  - test/dummy/test/components/smart_form_test.rb
522
522
  - test/dummy/test/components/smart_table_test.rb
523
523
  - test/dummy/test/components/widget_box_test.rb
524
+ - test/dummy/test/controllers/admin/categories_controller_test.rb
524
525
  - test/dummy/test/controllers/admin/parts_controller_test.rb
525
526
  - test/dummy/test/controllers/admin/widgets_controller_test.rb
526
527
  - test/dummy/test/controllers/demo_controller_test.rb
@@ -856,6 +857,7 @@ test_files:
856
857
  - test/dummy/test/components/smart_form_test.rb
857
858
  - test/dummy/test/components/smart_table_test.rb
858
859
  - test/dummy/test/components/widget_box_test.rb
860
+ - test/dummy/test/controllers/admin/categories_controller_test.rb
859
861
  - test/dummy/test/controllers/admin/parts_controller_test.rb
860
862
  - test/dummy/test/controllers/admin/widgets_controller_test.rb
861
863
  - test/dummy/test/controllers/demo_controller_test.rb