dry_crud 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/README.rdoc +24 -19
  2. data/Rakefile +12 -4
  3. data/VERSION +1 -1
  4. data/lib/generators/dry_crud/dry_crud_generator.rb +7 -7
  5. data/lib/generators/dry_crud/templates/app/assets/stylesheets/crud.scss +18 -7
  6. data/lib/generators/dry_crud/templates/app/assets/stylesheets/sample.scss +13 -18
  7. data/lib/generators/dry_crud/templates/app/controllers/crud_controller.rb +74 -87
  8. data/lib/generators/dry_crud/templates/app/controllers/list_controller.rb +95 -50
  9. data/lib/generators/dry_crud/templates/app/helpers/crud_helper.rb +11 -11
  10. data/lib/generators/dry_crud/templates/app/helpers/list_helper.rb +7 -7
  11. data/lib/generators/dry_crud/templates/app/helpers/standard_form_builder.rb +55 -27
  12. data/lib/generators/dry_crud/templates/app/helpers/standard_helper.rb +83 -30
  13. data/lib/generators/dry_crud/templates/app/helpers/standard_table_builder.rb +5 -13
  14. data/lib/generators/dry_crud/templates/app/views/layouts/_flash.html.erb +1 -4
  15. data/lib/generators/dry_crud/templates/app/views/layouts/_flash.html.haml +1 -3
  16. data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.erb +6 -6
  17. data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.haml +5 -3
  18. data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb +13 -11
  19. data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.haml +15 -15
  20. data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb +10 -10
  21. data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb +2 -2
  22. data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.haml +2 -2
  23. data/lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb +1 -0
  24. data/lib/generators/dry_crud/templates/config/locales/en_crud.yml +1 -0
  25. data/lib/generators/dry_crud/templates/test/crud_test_model.rb +72 -17
  26. data/lib/generators/dry_crud/templates/test/custom_assertions.rb +1 -1
  27. data/lib/generators/dry_crud/templates/test/functional/crud_controller_test_helper.rb +42 -26
  28. data/lib/generators/dry_crud/templates/test/functional/crud_test_models_controller_test.rb +135 -29
  29. data/lib/generators/dry_crud/templates/test/unit/custom_assertions_test.rb +4 -4
  30. data/lib/generators/dry_crud/templates/test/unit/helpers/crud_helper_test.rb +4 -2
  31. data/lib/generators/dry_crud/templates/test/unit/helpers/list_helper_test.rb +2 -0
  32. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_form_builder_test.rb +94 -16
  33. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_helper_test.rb +58 -18
  34. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_table_builder_test.rb +4 -4
  35. data/test/templates/Gemfile +1 -0
  36. data/test/templates/app/controllers/admin/cities_controller.rb +0 -7
  37. data/test/templates/app/controllers/admin/countries_controller.rb +2 -3
  38. data/test/templates/app/controllers/ajax_controller.rb +2 -0
  39. data/test/templates/app/controllers/people_controller.rb +1 -1
  40. data/test/templates/app/models/city.rb +2 -0
  41. data/test/templates/app/models/country.rb +2 -0
  42. data/test/templates/app/models/person.rb +2 -0
  43. data/test/templates/app/views/admin/cities/_attrs.html.erb +1 -0
  44. data/test/templates/app/views/admin/cities/_attrs.html.haml +1 -0
  45. data/test/templates/app/views/admin/cities/_form.html.erb +7 -1
  46. data/test/templates/app/views/admin/cities/_form.html.haml +5 -1
  47. data/test/templates/app/views/admin/cities/_list.html.erb +1 -4
  48. data/test/templates/app/views/admin/cities/_list.html.haml +1 -3
  49. data/test/templates/app/views/ajax/_actions_show.html.erb +4 -0
  50. data/test/templates/app/views/ajax/_actions_show.html.haml +4 -0
  51. data/test/templates/app/views/ajax/_form.html.erb +2 -0
  52. data/test/templates/app/views/ajax/_form.html.haml +2 -0
  53. data/test/templates/app/views/ajax/edit.js.erb +1 -0
  54. data/test/templates/app/views/ajax/edit.js.haml +1 -0
  55. data/test/templates/app/views/ajax/show.js.erb +1 -0
  56. data/test/templates/app/views/ajax/show.js.haml +1 -0
  57. data/test/templates/app/views/ajax/update.js.erb +5 -0
  58. data/test/templates/app/views/ajax/update.js.haml +5 -0
  59. data/test/templates/app/views/layouts/_nav.html.erb +6 -0
  60. data/test/templates/app/views/layouts/_nav.html.haml +5 -0
  61. data/test/templates/app/views/layouts/bootstrap.html.erb +68 -0
  62. data/test/templates/app/views/layouts/bootstrap.html.haml +49 -0
  63. data/test/templates/app/views/people/_attrs.html.erb +2 -2
  64. data/test/templates/app/views/people/_attrs.html.haml +2 -2
  65. data/test/templates/config/routes.rb +5 -5
  66. data/test/templates/db/migrate/20100511174904_create_people_and_cities.rb +1 -1
  67. data/test/templates/db/seeds.rb +52 -52
  68. data/test/templates/test/functional/admin/cities_controller_test.rb +15 -15
  69. data/test/templates/test/functional/admin/countries_controller_test.rb +4 -5
  70. data/test/templates/test/functional/people_controller_test.rb +32 -4
  71. metadata +22 -9
  72. data/lib/generators/dry_crud/templates/app/views/layouts/_menu.html.erb +0 -3
  73. data/lib/generators/dry_crud/templates/app/views/layouts/_menu.html.haml +0 -3
  74. data/test/templates/app/views/layouts/_menu.html.erb +0 -3
  75. data/test/templates/app/views/layouts/_menu.html.haml +0 -3
@@ -13,62 +13,62 @@ lon = City.create!(:name => 'London', :country => gb)
13
13
  br = City.create!(:name => 'Berlin', :country => de)
14
14
 
15
15
  Person.create!(:name => 'Albert Einstein',
16
- :city => be,
17
- :children => 2,
18
- :rating => 9.8,
19
- :income => 84000,
20
- :birthdate => '1904-10-18',
21
- :gets_up_at => '05:43',
22
- :remarks => "Great physician\n Good cyclist")
16
+ :city => be,
17
+ :children => 2,
18
+ :rating => 9.8,
19
+ :income => 84000,
20
+ :birthdate => '1904-10-18',
21
+ :gets_up_at => '05:43',
22
+ :remarks => "Great physician\n Good cyclist")
23
23
  Person.create!(:name => 'Adolf Ogi',
24
- :city => be,
25
- :children => 3,
26
- :rating => 4.2,
27
- :income => 264000,
28
- :birthdate => '1938-01-22',
29
- :gets_up_at => '04:30',
30
- :remarks => 'Freude herrscht!')
24
+ :city => be,
25
+ :children => 3,
26
+ :rating => 4.2,
27
+ :income => 264000,
28
+ :birthdate => '1938-01-22',
29
+ :gets_up_at => '04:30',
30
+ :remarks => 'Freude herrscht!')
31
31
  Person.create!(:name => 'Jay Z',
32
- :city => ny,
33
- :children => 0,
34
- :rating => 7.2,
35
- :income => 868345,
36
- :birthdate => '1976-05-02',
37
- :gets_up_at => '12:00',
38
- :last_seen => '2011-03-10 17:29',
39
- :cool => true,
40
- :remarks => "If got 99 problems\nbut you *** ain't one\nTschie")
32
+ :city => ny,
33
+ :children => 0,
34
+ :rating => 7.2,
35
+ :income => 868345,
36
+ :birthdate => '1976-05-02',
37
+ :gets_up_at => '12:00',
38
+ :last_seen => '2011-03-10 17:29',
39
+ :cool => true,
40
+ :remarks => "If got 99 problems\nbut you *** ain't one\nTschie")
41
41
  Person.create!(:name => 'Queen Elisabeth',
42
- :city => lon,
43
- :children => 1,
44
- :rating => 1.56,
45
- :income => 345622,
46
- :birthdate => '1927-08-11',
47
- :gets_up_at => '17:12',
48
- :remarks => '')
42
+ :city => lon,
43
+ :children => 1,
44
+ :rating => 1.56,
45
+ :income => 345622,
46
+ :birthdate => '1927-08-11',
47
+ :gets_up_at => '17:12',
48
+ :remarks => '')
49
49
  Person.create!(:name => 'Schopenhauer',
50
- :city => br,
51
- :children => 7,
52
- :rating => 6.9,
53
- :income => 14000,
54
- :birthdate => '1788-10-18',
55
- :last_seen => '1854-09-01 11:01',
56
- :remarks => 'Neminem laede, immo omnes, quantum potes, iuva.')
50
+ :city => br,
51
+ :children => 7,
52
+ :rating => 6.9,
53
+ :income => 14000,
54
+ :birthdate => '1788-10-18',
55
+ :last_seen => '1854-09-01 11:01',
56
+ :remarks => 'Neminem laede, immo omnes, quantum potes, iuva.')
57
57
  Person.create!(:name => 'ZZ Top',
58
- :city => ny,
59
- :children => 185,
60
- :rating => 1.8,
61
- :income => 84000,
62
- :birthdate => '1948-03-18',
63
- :cool => true,
64
- :remarks => 'zzz..')
58
+ :city => ny,
59
+ :children => 185,
60
+ :rating => 1.8,
61
+ :income => 84000,
62
+ :birthdate => '1948-03-18',
63
+ :cool => true,
64
+ :remarks => 'zzz..')
65
65
  Person.create!(:name => 'Andy Warhol',
66
- :city => ny,
67
- :children => 0,
68
- :rating => 7.5,
69
- :income => 123000,
70
- :birthdate => '1938-09-08',
71
- :last_seen => '1984-10-10 23:39',
72
- :remarks => 'Tomato Soup')
73
-
66
+ :city => ny,
67
+ :children => 0,
68
+ :rating => 7.5,
69
+ :income => 123000,
70
+ :birthdate => '1938-09-08',
71
+ :last_seen => '1984-10-10 23:39',
72
+ :remarks => 'Tomato Soup')
73
+
74
74
  end
@@ -13,37 +13,37 @@ class Admin::CitiesControllerTest < ActionController::TestCase
13
13
 
14
14
  def test_index
15
15
  super
16
- assert_equal test_entry.country.cities.order('countries.code, cities.name').to_a, assigns(:entries).to_a
17
-
16
+ assert_equal test_entry.country.cities.order('countries.code, cities.name').to_a, entries.to_a
17
+
18
+ assert_equal @controller.send(:entries), assigns(:cities)
18
19
  assert_equal [:admin, test_entry.country], @controller.send(:parents)
20
+ assert_equal test_entry.country, assigns(:country)
19
21
  assert_equal test_entry.country, @controller.send(:parent)
20
- assert_equal test_entry.country.cities, @controller.send(:model_scope)
22
+ assert_equal test_entry.country.cities.to_a, @controller.send(:model_scope).to_a
21
23
  assert_equal [:admin, test_entry.country, 2], @controller.send(:path_args, 2)
22
24
  end
23
25
 
24
26
  def test_show
25
- get :show, test_params(:id => test_entry.id)
26
- assert_redirected_to_index
27
- end
28
-
29
- def test_show_with_non_existing_id_raises_RecordNotFound #not
30
- get :show, test_params(:id => 9999)
31
- assert_redirected_to_index
27
+ super
28
+ assert_equal @controller.send(:entry), assigns(:city)
29
+ assert_equal [:admin, test_entry.country], @controller.send(:parents)
30
+ assert_equal test_entry.country, assigns(:country)
31
+ assert_equal test_entry.country, @controller.send(:parent)
32
32
  end
33
-
33
+ #
34
34
  def test_create
35
35
  super
36
- assert_equal test_entry.country, assigns(:entry).country
36
+ assert_equal test_entry.country, entry.country
37
37
  end
38
38
 
39
39
  def test_destroy_with_inhabitants
40
40
  ny = cities(:ny)
41
41
  assert_no_difference('City.count') do
42
- request.env["HTTP_REFERER"]
42
+ @request.env["HTTP_REFERER"] = admin_country_city_url(ny.country, ny)
43
43
  delete :destroy, :country_id => ny.country_id, :id => ny.id
44
44
  end
45
- assert_redirected_to :action => 'show'
46
- assert flash.alert
45
+ assert_redirected_to [:admin, ny.country, ny]
46
+ assert_present flash[:alert]
47
47
  end
48
48
 
49
49
  protected
@@ -13,7 +13,7 @@ class Admin::CountriesControllerTest < ActionController::TestCase
13
13
 
14
14
  def test_index
15
15
  super
16
- assert_equal Country.order('name').all, assigns(:entries)
16
+ assert_equal Country.order('name').all, entries
17
17
  assert_equal [:admin], @controller.send(:parents)
18
18
  assert_nil @controller.send(:parent)
19
19
  assert_equal Country.scoped, @controller.send(:model_scope)
@@ -25,12 +25,11 @@ class Admin::CountriesControllerTest < ActionController::TestCase
25
25
  assert_redirected_to_index
26
26
  end
27
27
 
28
- def test_show_with_non_existing_id_raises_RecordNotFound #not
29
- get :show, test_params(:id => 9999)
28
+ protected
29
+
30
+ def assert_redirected_to_show2(entry)
30
31
  assert_redirected_to_index
31
32
  end
32
-
33
- protected
34
33
 
35
34
  def test_entry
36
35
  countries(:usa)
@@ -13,9 +13,9 @@ class PeopleControllerTest < ActionController::TestCase
13
13
 
14
14
  def test_index
15
15
  super
16
- assert_equal 2, assigns(:entries).size
17
- assert_equal Person.includes(:city => :country).order('people.name, countries.code, cities.name').all, assigns(:entries)
18
-
16
+ assert_equal 2, entries.size
17
+ assert_equal Person.includes(:city => :country).order('people.name, countries.code, cities.name').all, entries
18
+
19
19
  assert_equal [], @controller.send(:parents)
20
20
  assert_nil @controller.send(:parent)
21
21
  assert_equal Person.scoped, @controller.send(:model_scope)
@@ -24,7 +24,35 @@ class PeopleControllerTest < ActionController::TestCase
24
24
 
25
25
  def test_index_search
26
26
  super
27
- assert_equal 1, assigns(:entries).size
27
+ assert_equal 1, entries.size
28
+ end
29
+
30
+ def test_show_js
31
+ get :show, :id => test_entry.id, :format => :js
32
+ assert_response :success
33
+ assert_template 'show'
34
+ assert_match /\$\('#content'\)/, response.body
35
+ end
36
+
37
+ def test_edit_js
38
+ get :edit, :id => test_entry.id, :format => :js
39
+ assert_response :success
40
+ assert_template 'edit'
41
+ assert_match /\$\('#content'\)/, response.body
42
+ end
43
+
44
+ def test_update_js
45
+ put :update, :id => test_entry.id, :format => :js, :person => {:name => 'New Name'}
46
+ assert_response :success
47
+ assert_template 'update'
48
+ assert_match /\$\('#content'\)/, response.body
49
+ end
50
+
51
+ def test_update_fail_js
52
+ put :update, :id => test_entry.id, :format => :js, :person => {:name => ' '}
53
+ assert_response :success
54
+ assert_template 'update'
55
+ assert_match /alert/, response.body
28
56
  end
29
57
 
30
58
  protected
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry_crud
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 1.5.0
10
+ version: 1.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pascal Zumkehr
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-02 00:00:00 +01:00
18
+ date: 2012-04-17 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  hash: 3
30
30
  segments:
@@ -81,8 +81,6 @@ files:
81
81
  - lib/generators/dry_crud/templates/app/views/crud/show.html.haml
82
82
  - lib/generators/dry_crud/templates/app/views/layouts/_flash.html.erb
83
83
  - lib/generators/dry_crud/templates/app/views/layouts/_flash.html.haml
84
- - lib/generators/dry_crud/templates/app/views/layouts/_menu.html.erb
85
- - lib/generators/dry_crud/templates/app/views/layouts/_menu.html.haml
86
84
  - lib/generators/dry_crud/templates/app/views/layouts/_nav.html.erb
87
85
  - lib/generators/dry_crud/templates/app/views/layouts/_nav.html.haml
88
86
  - lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb
@@ -99,6 +97,7 @@ files:
99
97
  - lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.haml
100
98
  - lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb
101
99
  - lib/generators/dry_crud/templates/app/views/shared/_labeled.html.haml
100
+ - lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb
102
101
  - lib/generators/dry_crud/templates/config/locales/en_crud.yml
103
102
  - lib/generators/dry_crud/templates/INSTALL
104
103
  - lib/generators/dry_crud/templates/test/crud_test_model.rb
@@ -124,6 +123,8 @@ files:
124
123
  - test/templates/app/models/person.rb
125
124
  - test/templates/app/views/admin/cities/_actions_index.html.erb
126
125
  - test/templates/app/views/admin/cities/_actions_index.html.haml
126
+ - test/templates/app/views/admin/cities/_attrs.html.erb
127
+ - test/templates/app/views/admin/cities/_attrs.html.haml
127
128
  - test/templates/app/views/admin/cities/_form.html.erb
128
129
  - test/templates/app/views/admin/cities/_form.html.haml
129
130
  - test/templates/app/views/admin/cities/_hello.html.erb
@@ -134,12 +135,24 @@ files:
134
135
  - test/templates/app/views/admin/countries/_list.html.haml
135
136
  - test/templates/app/views/ajax/_actions_index.html.erb
136
137
  - test/templates/app/views/ajax/_actions_index.html.haml
138
+ - test/templates/app/views/ajax/_actions_show.html.erb
139
+ - test/templates/app/views/ajax/_actions_show.html.haml
140
+ - test/templates/app/views/ajax/_form.html.erb
141
+ - test/templates/app/views/ajax/_form.html.haml
137
142
  - test/templates/app/views/ajax/_hello.html.erb
138
143
  - test/templates/app/views/ajax/_hello.html.haml
139
144
  - test/templates/app/views/ajax/ajax.js.erb
140
145
  - test/templates/app/views/ajax/ajax.js.haml
141
- - test/templates/app/views/layouts/_menu.html.erb
142
- - test/templates/app/views/layouts/_menu.html.haml
146
+ - test/templates/app/views/ajax/edit.js.erb
147
+ - test/templates/app/views/ajax/edit.js.haml
148
+ - test/templates/app/views/ajax/show.js.erb
149
+ - test/templates/app/views/ajax/show.js.haml
150
+ - test/templates/app/views/ajax/update.js.erb
151
+ - test/templates/app/views/ajax/update.js.haml
152
+ - test/templates/app/views/layouts/_nav.html.erb
153
+ - test/templates/app/views/layouts/_nav.html.haml
154
+ - test/templates/app/views/layouts/bootstrap.html.erb
155
+ - test/templates/app/views/layouts/bootstrap.html.haml
143
156
  - test/templates/app/views/people/_attrs.html.erb
144
157
  - test/templates/app/views/people/_attrs.html.haml
145
158
  - test/templates/app/views/people/_list.html.erb
@@ -1,3 +0,0 @@
1
- <li><%= link_to "Link1", "/path1" %></li>
2
- <li><%= link_to "Link2", "/path2" %></li>
3
- <li><%= link_to "Link3", "/path3" %></li>
@@ -1,3 +0,0 @@
1
- %li= link_to "Link1", "/path1"
2
- %li= link_to "Link2", "/path2"
3
- %li= link_to "Link3", "/path3"
@@ -1,3 +0,0 @@
1
- <li><%= link_to t(:'global.menu.people'), people_path %></li>
2
- <li><%= link_to t(:'global.menu.countries'), admin_countries_path %></li>
3
- <li><%= link_to t(:'global.menu.vips'), vips_path %></li>
@@ -1,3 +0,0 @@
1
- %li= link_to t(:'global.menu.people'), people_path
2
- %li= link_to t(:'global.menu.countries'), admin_countries_path
3
- %li= link_to t(:'global.menu.vips'), vips_path