dry_crud 1.2.0 → 1.2.5

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 (38) hide show
  1. data/README.rdoc +28 -11
  2. data/Rakefile +2 -1
  3. data/VERSION +1 -1
  4. data/lib/generators/dry_crud/templates/INSTALL +0 -1
  5. data/lib/generators/dry_crud/templates/app/controllers/crud_controller.rb +11 -183
  6. data/lib/generators/dry_crud/templates/app/controllers/list_controller.rb +212 -0
  7. data/lib/generators/dry_crud/templates/app/helpers/crud_helper.rb +10 -20
  8. data/lib/generators/dry_crud/templates/app/helpers/list_helper.rb +25 -0
  9. data/lib/generators/dry_crud/templates/app/helpers/standard_helper.rb +5 -4
  10. data/lib/generators/dry_crud/templates/app/helpers/standard_table_builder.rb +2 -2
  11. data/lib/generators/dry_crud/templates/app/views/crud/edit.html.erb +1 -1
  12. data/lib/generators/dry_crud/templates/app/views/crud/new.html.erb +1 -1
  13. data/lib/generators/dry_crud/templates/app/views/crud/show.html.erb +1 -1
  14. data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb +5 -1
  15. data/lib/generators/dry_crud/templates/app/views/list/_actions_index.html.erb +0 -0
  16. data/lib/generators/dry_crud/templates/app/views/list/_list.html.erb +1 -0
  17. data/lib/generators/dry_crud/templates/app/views/list/_search.html.erb +7 -0
  18. data/lib/generators/dry_crud/templates/app/views/{crud → list}/index.html.erb +1 -1
  19. data/lib/generators/dry_crud/templates/public/stylesheets/crud.css +13 -10
  20. data/lib/generators/dry_crud/templates/test/crud_test_model.rb +50 -25
  21. data/lib/generators/dry_crud/templates/test/custom_assertions.rb +8 -0
  22. data/lib/generators/dry_crud/templates/test/functional/crud_test_models_controller_test.rb +23 -3
  23. data/lib/generators/dry_crud/templates/test/unit/custom_assertions_test.rb +18 -0
  24. data/lib/generators/dry_crud/templates/test/unit/helpers/crud_helper_test.rb +22 -75
  25. data/lib/generators/dry_crud/templates/test/unit/helpers/list_helper_test.rb +139 -0
  26. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_form_builder_test.rb +4 -7
  27. data/lib/generators/dry_crud/templates/test/unit/helpers/standard_helper_test.rb +6 -10
  28. data/test/templates/app/controllers/people_controller.rb +1 -0
  29. data/test/templates/app/controllers/vips_controller.rb +24 -0
  30. data/test/templates/app/views/cities/_list.html.erb +3 -3
  31. data/test/templates/app/views/layouts/application.html.erb +33 -0
  32. data/test/templates/app/views/people/_list.html.erb +1 -0
  33. data/test/templates/config/routes.rb +2 -0
  34. data/test/templates/db/seeds.rb +1 -1
  35. data/test/templates/public/stylesheets/demo.css +113 -0
  36. metadata +15 -7
  37. data/lib/generators/dry_crud/templates/app/views/crud/_search.html.erb +0 -8
  38. data/test/templates/app/views/layouts/crud.html.erb +0 -26
@@ -111,7 +111,7 @@ class StandardHelperTest < ActionView::TestCase
111
111
  m = crud_test_models(:AAAAA)
112
112
  assert_equal '1.10', format_type(m, :rating)
113
113
 
114
- m.rating = 3.145
114
+ m.rating = 3.145001 # you never know with these floats..
115
115
  assert_equal '3.15', format_type(m, :rating)
116
116
  end
117
117
 
@@ -124,6 +124,11 @@ class StandardHelperTest < ActionView::TestCase
124
124
  m = crud_test_models(:AAAAA)
125
125
  assert_equal '1910-01-01', format_type(m, :birthdate)
126
126
  end
127
+
128
+ test "format datetime column" do
129
+ m = crud_test_models(:AAAAA)
130
+ assert_equal f(m.created_at.to_date) + " " + f(m.created_at.to_time), format_type(m, :created_at)
131
+ end
127
132
 
128
133
  test "format text column" do
129
134
  m = crud_test_models(:AAAAA)
@@ -212,13 +217,4 @@ class StandardHelperTest < ActionView::TestCase
212
217
  assert_match /input .*?type="submit" .*?value="Save"/, f
213
218
  end
214
219
 
215
- private
216
-
217
- def with_test_routing
218
- with_routing do |set|
219
- set.draw { resources :crud_test_models }
220
- yield
221
- end
222
- end
223
-
224
220
  end
@@ -1,6 +1,7 @@
1
1
  class PeopleController < AjaxController
2
2
 
3
3
  self.search_columns = [:name, :children, :rating, :income, :birthdate, :remarks]
4
+
4
5
  self.sort_mappings = {:city_id => 'cities.name'}
5
6
 
6
7
  protected
@@ -0,0 +1,24 @@
1
+ class VipsController < ListController
2
+
3
+ self.search_columns = [:name, :children, :rating, :remarks]
4
+
5
+ self.sort_mappings = {:city_id => 'cities.name'}
6
+
7
+ def index
8
+ @title = 'Listing VIPs'
9
+ super
10
+ end
11
+
12
+ protected
13
+
14
+ class << self
15
+ def model_class
16
+ Person
17
+ end
18
+ end
19
+
20
+ def list_entries
21
+ super.where('rating > 5').includes(:city).order('people.name, cities.country_code, cities.name')
22
+ end
23
+
24
+ end
@@ -1,4 +1,4 @@
1
- <%= crud_table :name, :country_code do |t|
2
- t.col {|e| link_action_edit(e) }
3
- t.col {|e| link_action_destroy(e) }
1
+ <%= crud_table *default_attrs do |t|
2
+ t.col('', :class => 'center') {|e| link_action_edit(e) }
3
+ t.col('', :class => 'center') {|e| link_action_destroy(e) }
4
4
  end %>
@@ -0,0 +1,33 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title><%= @title %></title>
8
+ <%= stylesheet_link_tag 'crud', 'demo' %>
9
+ <%= javascript_include_tag :all %>
10
+ <%= csrf_meta_tag %>
11
+ </head>
12
+ <body>
13
+
14
+ <div id="content">
15
+ <ul id="menu">
16
+ <li><%= link_to 'People', people_path %></li>
17
+ <li><%= link_to 'Cities', cities_path %></li>
18
+ <li><%= link_to 'VIPs', vips_path %></li>
19
+ </ul>
20
+
21
+ <h1><%= @title %></h1>
22
+
23
+ <% if flash[:notice].present? %>
24
+ <div id="flash_notice"><%= flash[:notice] %></div>
25
+ <% elsif flash[:alert].present? %>
26
+ <div id="flash_alert"><%= flash[:alert] %></div>
27
+ <% end %>
28
+
29
+ <%= yield %>
30
+ </div>
31
+
32
+ </body>
33
+ </html>
@@ -0,0 +1 @@
1
+ <%= crud_table :name, :city_id, :birthdate, :children, :income %>
@@ -12,6 +12,8 @@ TestApp::Application.routes.draw do
12
12
  end
13
13
  end
14
14
 
15
+ match 'vips' => 'vips#index', :as => :vips
16
+
15
17
  # Install the default routes as the lowest priority.
16
18
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
17
19
  # consider removing or commenting them out if you're using named routes and resources.
@@ -24,7 +24,7 @@ Person.create!(:name => 'Jay Z',
24
24
  :rating => 7.2,
25
25
  :income => 868345,
26
26
  :birthdate => '1976-05-02',
27
- :remarks => "If got 99 problems\nbut you bitch ain't one\nTschie")
27
+ :remarks => "If got 99 problems\nbut you *** ain't one\nTschie")
28
28
  Person.create!(:name => 'Queen Elisabeth',
29
29
  :city => lon,
30
30
  :children => 1,
@@ -0,0 +1,113 @@
1
+ body {
2
+ text-align: center;
3
+ margin: 0pt;
4
+ background-color: #ddf;
5
+ }
6
+
7
+ #content {
8
+ padding: 20pt 20pt;
9
+ margin: 0 auto;
10
+ text-align: left;
11
+ width: 600pt;
12
+ height: 100%;
13
+ background-color: #f6f6ff;
14
+ }
15
+
16
+ h1 {
17
+ font-size: 150%;
18
+ margin: 30px 0;
19
+ }
20
+
21
+ table {
22
+ border-collapse: collapse;
23
+ width: 100%;
24
+ padding: 0;
25
+ }
26
+
27
+ td {
28
+ padding: 2px 4px;
29
+ }
30
+
31
+ th {
32
+ text-align: left;
33
+ background-color: #2580a2;
34
+ color: white;
35
+ font-weight: bold;
36
+ padding: 2px 4px;
37
+ }
38
+
39
+ th a {
40
+ text-decoration: none;
41
+ color: white;
42
+ }
43
+
44
+ th a:hover {
45
+ text-decoration: underline;
46
+ }
47
+
48
+ table.list th a {
49
+ color: white;
50
+ }
51
+
52
+ a {
53
+ color: #2580a2;
54
+ text-decoration: none;
55
+ }
56
+
57
+ a:visited {
58
+ color: #2580a2;
59
+ }
60
+
61
+ a:hover {
62
+ text-decoration: underline;
63
+ }
64
+
65
+ a.action {
66
+ color: #2580a2;
67
+ text-decoration: none;
68
+ }
69
+
70
+ a:visited.action {
71
+ color: #2580a2;
72
+ }
73
+
74
+ a.action:hover {
75
+ text-decoration: none;
76
+
77
+ }
78
+
79
+ #menu {
80
+ background: #333;
81
+ -moz-box-shadow: 0px 3px 3px #2580a2;
82
+ -webkit-box-shadow: 0px 3px 3px #2580a2;
83
+ box-shadow: 0px 3px 3px #2580a2;
84
+ float: left;
85
+ list-style: none;
86
+ margin: -20pt;
87
+ padding: 0 20px;
88
+ width: 610pt;
89
+
90
+ }
91
+
92
+ #menu li {
93
+ float: left;
94
+ font-size: 110%;
95
+ margin: 0;
96
+ padding: 0;
97
+ }
98
+
99
+ #menu a {
100
+ background: #333 bottom right no-repeat;
101
+ color: #ddd;
102
+ display: block;
103
+ float: left;
104
+ margin: 0;
105
+ padding: 4px 12px;
106
+ text-decoration: none;
107
+ }
108
+
109
+ #menu a:hover {
110
+ background: #2580a2 bottom center no-repeat;
111
+ color: #fff;
112
+ padding-bottom: 4px;
113
+ }
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: 31
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
9
+ - 5
10
+ version: 1.2.5
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: 2010-11-26 00:00:00 +01:00
18
+ date: 2010-12-30 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -48,8 +48,10 @@ extra_rdoc_files:
48
48
  files:
49
49
  - lib/generators/dry_crud/dry_crud_generator.rb
50
50
  - lib/generators/dry_crud/templates/app/controllers/crud_controller.rb
51
+ - lib/generators/dry_crud/templates/app/controllers/list_controller.rb
51
52
  - lib/generators/dry_crud/templates/app/controllers/render_inheritable.rb
52
53
  - lib/generators/dry_crud/templates/app/helpers/crud_helper.rb
54
+ - lib/generators/dry_crud/templates/app/helpers/list_helper.rb
53
55
  - lib/generators/dry_crud/templates/app/helpers/standard_form_builder.rb
54
56
  - lib/generators/dry_crud/templates/app/helpers/standard_helper.rb
55
57
  - lib/generators/dry_crud/templates/app/helpers/standard_table_builder.rb
@@ -59,12 +61,14 @@ files:
59
61
  - lib/generators/dry_crud/templates/app/views/crud/_attrs.html.erb
60
62
  - lib/generators/dry_crud/templates/app/views/crud/_form.html.erb
61
63
  - lib/generators/dry_crud/templates/app/views/crud/_list.html.erb
62
- - lib/generators/dry_crud/templates/app/views/crud/_search.html.erb
63
64
  - lib/generators/dry_crud/templates/app/views/crud/edit.html.erb
64
- - lib/generators/dry_crud/templates/app/views/crud/index.html.erb
65
65
  - lib/generators/dry_crud/templates/app/views/crud/new.html.erb
66
66
  - lib/generators/dry_crud/templates/app/views/crud/show.html.erb
67
67
  - lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb
68
+ - lib/generators/dry_crud/templates/app/views/list/_actions_index.html.erb
69
+ - lib/generators/dry_crud/templates/app/views/list/_list.html.erb
70
+ - lib/generators/dry_crud/templates/app/views/list/_search.html.erb
71
+ - lib/generators/dry_crud/templates/app/views/list/index.html.erb
68
72
  - lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb
69
73
  - lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb
70
74
  - lib/generators/dry_crud/templates/INSTALL
@@ -75,6 +79,7 @@ files:
75
79
  - lib/generators/dry_crud/templates/test/functional/crud_test_models_controller_test.rb
76
80
  - lib/generators/dry_crud/templates/test/unit/custom_assertions_test.rb
77
81
  - lib/generators/dry_crud/templates/test/unit/helpers/crud_helper_test.rb
82
+ - lib/generators/dry_crud/templates/test/unit/helpers/list_helper_test.rb
78
83
  - lib/generators/dry_crud/templates/test/unit/helpers/render_inheritable_test.rb
79
84
  - lib/generators/dry_crud/templates/test/unit/helpers/standard_form_builder_test.rb
80
85
  - lib/generators/dry_crud/templates/test/unit/helpers/standard_helper_test.rb
@@ -84,6 +89,7 @@ files:
84
89
  - test/templates/app/controllers/application_controller.rb
85
90
  - test/templates/app/controllers/cities_controller.rb
86
91
  - test/templates/app/controllers/people_controller.rb
92
+ - test/templates/app/controllers/vips_controller.rb
87
93
  - test/templates/app/helpers/people_helper.rb
88
94
  - test/templates/app/models/city.rb
89
95
  - test/templates/app/models/person.rb
@@ -93,11 +99,13 @@ files:
93
99
  - test/templates/app/views/cities/_form.html.erb
94
100
  - test/templates/app/views/cities/_hello.html.erb
95
101
  - test/templates/app/views/cities/_list.html.erb
96
- - test/templates/app/views/layouts/crud.html.erb
102
+ - test/templates/app/views/layouts/application.html.erb
97
103
  - test/templates/app/views/people/_attrs.html.erb
104
+ - test/templates/app/views/people/_list.html.erb
98
105
  - test/templates/config/routes.rb
99
106
  - test/templates/db/migrate/20100511174904_create_people_and_cities.rb
100
107
  - test/templates/db/seeds.rb
108
+ - test/templates/public/stylesheets/demo.css
101
109
  - test/templates/test/fixtures/cities.yml
102
110
  - test/templates/test/fixtures/people.yml
103
111
  - test/templates/test/functional/cities_controller_test.rb
@@ -1,8 +0,0 @@
1
- <%= form_tag(polymorphic_path(model_class), {:method => :get}) do %>
2
- <%= hidden_field_tag :sort, params[:sort] %>
3
- <%= hidden_field_tag :sort_dir, params[:sort_dir] %>
4
- <%= text_field_tag :q, params[:q] %>
5
- <%= submit_tag 'Search' %>
6
- <% end %>
7
-
8
- <br/>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
- <title><%= @title %></title>
8
- <%= stylesheet_link_tag 'crud' %>
9
- <%= javascript_include_tag :all %>
10
- <%= csrf_meta_tag %>
11
- </head>
12
- <body>
13
-
14
- <ul id="menu">
15
- <li><%= link_to 'People', people_path %></li>
16
- <li><%= link_to 'Cities', cities_path %></li>
17
- </ul>
18
-
19
- <h1><%= @title %></h1>
20
-
21
- <p id="flash_notice"><%= flash[:notice] %></p>
22
-
23
- <%= yield %>
24
-
25
- </body>
26
- </html>