dry_crud 1.2.7 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/README.rdoc +60 -27
  2. data/Rakefile +3 -1
  3. data/VERSION +1 -1
  4. data/lib/generators/dry_crud/dry_crud_generator.rb +3 -3
  5. data/lib/generators/dry_crud/templates/INSTALL +3 -1
  6. data/lib/generators/dry_crud/templates/app/controllers/crud_controller.rb +106 -90
  7. data/lib/generators/dry_crud/templates/app/controllers/list_controller.rb +90 -74
  8. data/lib/generators/dry_crud/templates/app/controllers/render_inheritable.rb +34 -33
  9. data/lib/generators/dry_crud/templates/app/helpers/crud_helper.rb +39 -23
  10. data/lib/generators/dry_crud/templates/app/helpers/list_helper.rb +11 -9
  11. data/lib/generators/dry_crud/templates/app/helpers/standard_form_builder.rb +55 -47
  12. data/lib/generators/dry_crud/templates/app/helpers/standard_helper.rb +134 -86
  13. data/lib/generators/dry_crud/templates/app/helpers/standard_table_builder.rb +41 -35
  14. data/lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.erb +1 -0
  15. data/lib/generators/dry_crud/templates/app/views/crud/edit.html.erb +3 -3
  16. data/lib/generators/dry_crud/templates/app/views/crud/new.html.erb +2 -2
  17. data/lib/generators/dry_crud/templates/app/views/crud/show.html.erb +3 -3
  18. data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb +9 -7
  19. data/lib/generators/dry_crud/templates/app/views/list/_search.html.erb +1 -1
  20. data/lib/generators/dry_crud/templates/app/views/list/index.html.erb +4 -4
  21. data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb +3 -1
  22. data/lib/generators/dry_crud/templates/config/locales/en_crud.yml +63 -0
  23. data/lib/generators/dry_crud/templates/test/crud_test_model.rb +93 -58
  24. data/lib/generators/dry_crud/templates/test/custom_assertions.rb +24 -13
  25. data/lib/generators/dry_crud/templates/test/functional/crud_controller_test_helper.rb +26 -56
  26. data/lib/generators/dry_crud/templates/test/functional/crud_test_models_controller_test.rb +47 -41
  27. data/lib/generators/dry_crud/templates/test/unit/custom_assertions_test.rb +28 -24
  28. data/lib/generators/dry_crud/templates/test/unit/helpers/crud_helper_test.rb +20 -34
  29. data/lib/generators/dry_crud/templates/test/unit/helpers/list_helper_test.rb +39 -53
  30. data/lib/generators/dry_crud/templates/test/unit/helpers/render_inheritable_test.rb +33 -33
  31. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_form_builder_test.rb +27 -27
  32. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_helper_test.rb +103 -50
  33. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_table_builder_test.rb +52 -24
  34. data/test/templates/Gemfile +34 -0
  35. data/test/templates/app/controllers/ajax_controller.rb +3 -3
  36. data/test/templates/app/controllers/application_controller.rb +1 -1
  37. data/test/templates/app/controllers/cities_controller.rb +2 -5
  38. data/test/templates/app/controllers/people_controller.rb +5 -5
  39. data/test/templates/app/controllers/vips_controller.rb +6 -11
  40. data/test/templates/app/helpers/people_helper.rb +2 -2
  41. data/test/templates/app/models/city.rb +9 -9
  42. data/test/templates/app/models/person.rb +5 -4
  43. data/test/templates/app/views/ajax/_actions_index.html.erb +2 -2
  44. data/test/templates/app/views/cities/_form.html.erb +5 -1
  45. data/test/templates/app/views/layouts/_menu.html.erb +3 -3
  46. data/test/templates/app/views/people/_attrs.html.erb +3 -3
  47. data/test/templates/config/database.yml +22 -0
  48. data/test/templates/config/locales/en_cities.yml +56 -0
  49. data/test/templates/config/routes.rb +5 -5
  50. data/test/templates/db/migrate/20100511174904_create_people_and_cities.rb +5 -2
  51. data/test/templates/db/seeds.rb +38 -29
  52. data/test/templates/test/functional/cities_controller_test.rb +12 -12
  53. data/test/templates/test/functional/people_controller_test.rb +10 -10
  54. metadata +11 -7
@@ -1,21 +1,21 @@
1
1
  TestApp::Application.routes.draw do
2
-
2
+
3
3
  resources :cities do
4
4
  collection do
5
5
  get :ajax
6
6
  end
7
- end
8
-
7
+ end
8
+
9
9
  resources :people do
10
10
  collection do
11
11
  get :ajax
12
12
  end
13
13
  end
14
-
14
+
15
15
  match 'vips' => 'vips#index', :as => :vips
16
16
 
17
17
  root :to => 'people#index'
18
-
18
+
19
19
  # Install the default routes as the lowest priority.
20
20
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
21
21
  # consider removing or commenting them out if you're using named routes and resources.
@@ -4,7 +4,7 @@ class CreatePeopleAndCities < ActiveRecord::Migration
4
4
  t.string :name, :null => false
5
5
  t.string :country_code, :null => false, :limit => 3
6
6
  end
7
-
7
+
8
8
  create_table :people do |t|
9
9
  t.string :name, :null => false
10
10
  t.integer :children
@@ -12,12 +12,15 @@ class CreatePeopleAndCities < ActiveRecord::Migration
12
12
  t.float :rating
13
13
  t.decimal :income, :precision => 14, :scale => 2
14
14
  t.date :birthdate
15
+ t.time :gets_up_at
16
+ t.datetime :last_seen
15
17
  t.text :remarks
18
+ t.boolean :cool, :null => false, :default => false
16
19
  end
17
20
  end
18
21
 
19
22
  def self.down
20
23
  drop_table :people
21
- drop_table :cities
24
+ drop_table :cities
22
25
  end
23
26
  end
@@ -6,54 +6,63 @@ sf = City.create!(:name => 'San Francisco', :country_code => 'USA')
6
6
  lon = City.create!(:name => 'London', :country_code => 'GB')
7
7
  br = City.create!(:name => 'Berlin', :country_code => 'DE')
8
8
 
9
- Person.create!(:name => 'Albert Einstein',
10
- :city => be,
11
- :children => 2,
12
- :rating => 9.8,
9
+ Person.create!(:name => 'Albert Einstein',
10
+ :city => be,
11
+ :children => 2,
12
+ :rating => 9.8,
13
13
  :income => 84000,
14
14
  :birthdate => '1904-10-18',
15
+ :gets_up_at => '05:43',
15
16
  :remarks => "Great physician\n Good cyclist")
16
- Person.create!(:name => 'Adolf Ogi',
17
- :city => be,
18
- :children => 3,
19
- :rating => 4.2,
17
+ Person.create!(:name => 'Adolf Ogi',
18
+ :city => be,
19
+ :children => 3,
20
+ :rating => 4.2,
20
21
  :income => 264000,
21
22
  :birthdate => '1938-01-22',
23
+ :gets_up_at => '04:30',
22
24
  :remarks => 'Freude herrscht!')
23
- Person.create!(:name => 'Jay Z',
24
- :city => ny,
25
- :children => 0,
26
- :rating => 7.2,
25
+ Person.create!(:name => 'Jay Z',
26
+ :city => ny,
27
+ :children => 0,
28
+ :rating => 7.2,
27
29
  :income => 868345,
28
30
  :birthdate => '1976-05-02',
31
+ :gets_up_at => '12:00',
32
+ :last_seen => '2011-03-10 17:29',
33
+ :cool => true,
29
34
  :remarks => "If got 99 problems\nbut you *** ain't one\nTschie")
30
- Person.create!(:name => 'Queen Elisabeth',
31
- :city => lon,
32
- :children => 1,
33
- :rating => 1.56,
35
+ Person.create!(:name => 'Queen Elisabeth',
36
+ :city => lon,
37
+ :children => 1,
38
+ :rating => 1.56,
34
39
  :income => 345622,
35
40
  :birthdate => '1927-08-11',
41
+ :gets_up_at => '17:12',
36
42
  :remarks => '')
37
- Person.create!(:name => 'Schopenhauer',
38
- :city => br,
39
- :children => 7,
40
- :rating => 6.9,
43
+ Person.create!(:name => 'Schopenhauer',
44
+ :city => br,
45
+ :children => 7,
46
+ :rating => 6.9,
41
47
  :income => 14000,
42
48
  :birthdate => '1788-10-18',
49
+ :last_seen => '1854-09-01 11:01',
43
50
  :remarks => 'Neminem laede, immo omnes, quantum potes, iuva.')
44
- Person.create!(:name => 'ZZ Top',
45
- :city => ny,
46
- :children => 185,
47
- :rating => 1.8,
51
+ Person.create!(:name => 'ZZ Top',
52
+ :city => ny,
53
+ :children => 185,
54
+ :rating => 1.8,
48
55
  :income => 84000,
49
56
  :birthdate => '1948-03-18',
57
+ :cool => true,
50
58
  :remarks => 'zzz..')
51
- Person.create!(:name => 'Andy Warhol',
52
- :city => ny,
53
- :children => 0,
54
- :rating => 7.5,
59
+ Person.create!(:name => 'Andy Warhol',
60
+ :city => ny,
61
+ :children => 0,
62
+ :rating => 7.5,
55
63
  :income => 123000,
56
64
  :birthdate => '1938-09-08',
65
+ :last_seen => '1984-10-10 23:39',
57
66
  :remarks => 'Tomato Soup')
58
-
67
+
59
68
  end
@@ -1,45 +1,45 @@
1
1
  require 'test_helper'
2
- require File.join(File.dirname(__FILE__), 'crud_controller_test_helper')
2
+ require File.join('functional', 'crud_controller_test_helper')
3
3
 
4
4
  class CitiesControllerTest < ActionController::TestCase
5
-
5
+
6
6
  include CrudControllerTestHelper
7
-
7
+
8
8
  def test_setup
9
9
  assert_equal 3, City.count
10
10
  assert_recognizes({:controller => 'cities', :action => 'index'}, '/cities')
11
11
  assert_recognizes({:controller => 'cities', :action => 'show', :id => '1'}, '/cities/1')
12
12
  end
13
-
13
+
14
14
  def test_index
15
15
  super
16
16
  assert_equal 3, assigns(:entries).size
17
17
  assert_equal City.order('country_code, name').all, assigns(:entries)
18
18
  end
19
-
19
+
20
20
  def test_show
21
21
  get :show, :id => test_entry.id
22
22
  assert_redirected_to_index
23
23
  end
24
-
24
+
25
25
  def test_destroy_with_inhabitants
26
26
  ny = cities(:ny)
27
- assert_no_difference('City.count') do
27
+ assert_no_difference('City.count') do
28
28
  request.env["HTTP_REFERER"]
29
29
  delete :destroy, :id => ny.id
30
30
  end
31
31
  assert_redirected_to :action => 'show'
32
32
  assert flash.alert
33
33
  end
34
-
35
- protected
36
-
34
+
35
+ protected
36
+
37
37
  def test_entry
38
38
  cities(:rj)
39
39
  end
40
-
40
+
41
41
  def test_entry_attrs
42
42
  {:name => 'Rejkiavik', :country_code => 'IS'}
43
43
  end
44
-
44
+
45
45
  end
@@ -1,35 +1,35 @@
1
1
  require 'test_helper'
2
- require File.join(File.dirname(__FILE__), 'crud_controller_test_helper')
2
+ require File.join('functional', 'crud_controller_test_helper')
3
3
 
4
4
  class PeopleControllerTest < ActionController::TestCase
5
-
5
+
6
6
  include CrudControllerTestHelper
7
-
7
+
8
8
  def test_setup
9
9
  assert_equal 2, Person.count
10
10
  assert_recognizes({:controller => 'people', :action => 'index'}, '/people')
11
11
  assert_recognizes({:controller => 'people', :action => 'show', :id => '1'}, '/people/1')
12
12
  end
13
-
13
+
14
14
  def test_index
15
15
  super
16
16
  assert_equal 2, assigns(:entries).size
17
17
  assert_equal Person.includes(:city).order('people.name, cities.country_code, cities.name').all, assigns(:entries)
18
18
  end
19
-
19
+
20
20
  def test_index_search
21
21
  super
22
22
  assert_equal 1, assigns(:entries).size
23
23
  end
24
-
25
- protected
26
-
24
+
25
+ protected
26
+
27
27
  def test_entry
28
28
  people(:john)
29
29
  end
30
-
30
+
31
31
  def test_entry_attrs
32
32
  {:name => 'Fischers Fritz', :children => 2, :income => 120, :city_id => cities(:rj).id}
33
33
  end
34
-
34
+
35
35
  end
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: 17
5
- prerelease: false
4
+ hash: 27
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 7
10
- version: 1.2.7
8
+ - 3
9
+ - 0
10
+ version: 1.3.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: 2011-02-10 00:00:00 +01:00
18
+ date: 2011-03-28 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -72,6 +72,7 @@ files:
72
72
  - lib/generators/dry_crud/templates/app/views/list/index.html.erb
73
73
  - lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb
74
74
  - lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb
75
+ - lib/generators/dry_crud/templates/config/locales/en_crud.yml
75
76
  - lib/generators/dry_crud/templates/INSTALL
76
77
  - lib/generators/dry_crud/templates/public/images/actions/add.png
77
78
  - lib/generators/dry_crud/templates/public/images/actions/delete.png
@@ -108,9 +109,12 @@ files:
108
109
  - test/templates/app/views/layouts/_menu.html.erb
109
110
  - test/templates/app/views/people/_attrs.html.erb
110
111
  - test/templates/app/views/people/_list.html.erb
112
+ - test/templates/config/database.yml
113
+ - test/templates/config/locales/en_cities.yml
111
114
  - test/templates/config/routes.rb
112
115
  - test/templates/db/migrate/20100511174904_create_people_and_cities.rb
113
116
  - test/templates/db/seeds.rb
117
+ - test/templates/Gemfile
114
118
  - test/templates/test/fixtures/cities.yml
115
119
  - test/templates/test/fixtures/people.yml
116
120
  - test/templates/test/functional/cities_controller_test.rb
@@ -154,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
158
  requirements: []
155
159
 
156
160
  rubyforge_project:
157
- rubygems_version: 1.3.7
161
+ rubygems_version: 1.5.2
158
162
  signing_key:
159
163
  specification_version: 3
160
164
  summary: Generates DRY and specifically extendable CRUD controller, views and helpers for Rails applications