crudify 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/.gitignore +4 -2
  2. data/Gemfile.lock +57 -28
  3. data/README.md +121 -3
  4. data/Rakefile +3 -4
  5. data/crudify.gemspec +5 -2
  6. data/lib/crudify.rb +5 -1
  7. data/lib/crudify/base.rb +8 -7
  8. data/lib/crudify/class_methods.rb +35 -21
  9. data/lib/crudify/hook_methods.rb +30 -33
  10. data/lib/crudify/version.rb +1 -1
  11. data/test/dummy/Rakefile +7 -0
  12. data/test/dummy/app/controllers/admin/peanut_butters_controller.rb +5 -0
  13. data/test/dummy/app/controllers/application_controller.rb +3 -0
  14. data/test/dummy/app/controllers/jellies_controller.rb +7 -0
  15. data/test/dummy/app/models/jelly.rb +9 -0
  16. data/test/dummy/app/models/peanut_butter.rb +8 -0
  17. data/test/dummy/app/views/admin/peanut_butters/_fields.html.erb +4 -0
  18. data/test/dummy/app/views/admin/peanut_butters/edit.html.erb +11 -0
  19. data/test/dummy/app/views/admin/peanut_butters/index.html.erb +23 -0
  20. data/test/dummy/app/views/admin/peanut_butters/new.html.erb +11 -0
  21. data/test/dummy/app/views/admin/peanut_butters/show.html.erb +14 -0
  22. data/test/dummy/app/views/jellies/_fields.html.erb +8 -0
  23. data/test/dummy/app/views/jellies/edit.html.erb +11 -0
  24. data/test/dummy/app/views/jellies/index.html.erb +23 -0
  25. data/test/dummy/app/views/jellies/new.html.erb +11 -0
  26. data/test/dummy/app/views/jellies/show.html.erb +15 -0
  27. data/test/dummy/app/views/layouts/application.html.erb +72 -0
  28. data/test/dummy/app/views/shared/_error_messages.html.erb +9 -0
  29. data/test/dummy/config.ru +4 -0
  30. data/test/dummy/config/application.rb +45 -0
  31. data/test/dummy/config/boot.rb +10 -0
  32. data/test/dummy/config/database.yml +22 -0
  33. data/test/dummy/config/environment.rb +5 -0
  34. data/test/dummy/config/environments/development.rb +26 -0
  35. data/test/dummy/config/environments/production.rb +49 -0
  36. data/test/dummy/config/environments/test.rb +38 -0
  37. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/test/dummy/config/initializers/green_eggs_and_spam.rb +2 -0
  39. data/test/dummy/config/initializers/inflections.rb +10 -0
  40. data/test/dummy/config/initializers/mime_types.rb +5 -0
  41. data/test/dummy/config/initializers/secret_token.rb +7 -0
  42. data/test/dummy/config/initializers/session_store.rb +8 -0
  43. data/test/dummy/config/routes.rb +11 -0
  44. data/test/dummy/db/migrate/20110223073415_create_jellies.rb +13 -0
  45. data/test/dummy/db/migrate/20110223073427_create_peanut_butters.rb +12 -0
  46. data/test/dummy/db/schema.rb +28 -0
  47. data/test/dummy/public/404.html +26 -0
  48. data/test/dummy/public/422.html +26 -0
  49. data/test/dummy/public/500.html +26 -0
  50. data/{log/development.log → test/dummy/public/favicon.ico} +0 -0
  51. data/test/dummy/public/javascripts/application.js +2 -0
  52. data/test/dummy/public/javascripts/controls.js +965 -0
  53. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  54. data/test/dummy/public/javascripts/effects.js +1123 -0
  55. data/test/dummy/public/javascripts/index.html +239 -0
  56. data/test/dummy/public/javascripts/prototype.js +6001 -0
  57. data/test/dummy/public/javascripts/rails.js +191 -0
  58. data/test/dummy/public/stylesheets/styles.css +126 -0
  59. data/test/dummy/script/rails +6 -0
  60. data/test/functional/jellies_controller_test.rb +55 -0
  61. data/test/helper.rb +42 -31
  62. data/test/integration/demo_test.rb +79 -0
  63. data/test/{test_controller.rb → unit/crudify_test.rb} +17 -17
  64. metadata +149 -13
@@ -0,0 +1,79 @@
1
+ require 'helper'
2
+
3
+ class DemoTest < ActionController::IntegrationTest
4
+
5
+ def setup
6
+ Jelly.destroy_all
7
+ end
8
+
9
+ should "visit homepage with no jellies" do
10
+ visit root_path
11
+ assert page.has_content?('Listing Jellies')
12
+ assert page.has_content?('create a new jelly')
13
+ assert !page.has_content?('jelly named')
14
+ end
15
+
16
+ should "create a new jelly" do
17
+ visit new_jelly_path
18
+ assert page.has_content?('New Jelly')
19
+ fill_in 'Title', :with => 'Capybara and Banana'
20
+ fill_in 'Name', :with => 'Capyberry'
21
+ click_button 'create'
22
+ assert_equal jellies_path, current_path
23
+ assert_flash(:notice, '"Capybara and Banana" was successfully created.')
24
+ assert page.has_content?('Listing Jellies'), "Content should have title for index"
25
+ assert page.has_content?('Capyberry'), "Content should contain name of new jelly"
26
+ end
27
+
28
+ context "an existing jelly" do
29
+
30
+ setup do
31
+ @jelly = Jelly.create(:title => "Capygreen Times", :name => "Greenberry")
32
+ end
33
+
34
+ should "visit homepage with a jelly" do
35
+ visit root_path
36
+ assert page.has_content?('Listing Jellies')
37
+ assert page.has_content?('create a new jelly')
38
+ assert page.has_content?('jelly named Greenberry')
39
+ assert has_link?('read', :href => jelly_path(@jelly))
40
+ assert has_link?('update', :href => edit_jelly_path(@jelly))
41
+ end
42
+
43
+ should "be shown" do
44
+ visit jelly_path(@jelly)
45
+ assert page.has_content?('Show Jelly')
46
+ within "#content" do
47
+ assert page.has_content?(@jelly.title)
48
+ assert page.has_content?(@jelly.name)
49
+ end
50
+ end
51
+
52
+ should "get updated" do
53
+ visit edit_jelly_path(@jelly)
54
+ assert page.has_content?('Edit Jelly')
55
+ fill_in 'Title', :with => 'Banana Capy'
56
+ fill_in 'Name', :with => 'Capyberry and Banana'
57
+ click_button 'update'
58
+ assert_flash(:notice, '"Banana Capy" was successfully updated.')
59
+ assert page.has_content?('Listing Jellies')
60
+ within "#content" do
61
+ assert page.has_content?('Capyberry and Banana')
62
+ end
63
+ end
64
+
65
+ should "get deleted" do
66
+ visit jelly_path(@jelly)
67
+ assert page.has_content?('Show Jelly')
68
+ evaluate_script 'window.confirm = function() { return true; }'
69
+ click_link 'delete'
70
+ assert_flash(:notice, %("#{@jelly.title}" was successfully removed.))
71
+ assert page.has_content?('Listing Jellies')
72
+ within "#content" do
73
+ assert !page.has_content?(@jelly.name)
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -1,15 +1,16 @@
1
- require_relative 'helper'
2
-
3
-
4
- def assert_has_method?(methods, name)
5
-
6
- end
1
+ require 'helper'
7
2
 
8
3
 
9
- class TestController < Test::Unit::TestCase
4
+ class CrudifyTest < Test::Unit::TestCase
10
5
 
11
6
  def setup
12
- @controller = CrudifyTestController.new
7
+
8
+ Jelly.destroy_all
9
+ 10.times{|i|
10
+ Jelly.create(:title => "Yummy Jelly #{i}", :name => "Sample #{i}")
11
+ }
12
+
13
+ @controller = JelliesController.new
13
14
  @controller.params = {}
14
15
  end
15
16
 
@@ -21,8 +22,7 @@ class TestController < Test::Unit::TestCase
21
22
  :search_all_jellies
22
23
  ].each do |method|
23
24
  assert @controller.methods.include?(method), "Should have #{method}"
24
- end
25
-
25
+ end
26
26
  end
27
27
 
28
28
  should "have private hook methods" do
@@ -44,14 +44,14 @@ class TestController < Test::Unit::TestCase
44
44
 
45
45
  should "get collection" do
46
46
  jellies = @controller.send(:find_all_jellies)
47
- assert_equal 3, jellies.length
47
+ assert_equal 10, jellies.length, "Confirm 10 total jellies"
48
48
  end
49
49
 
50
- #should "paginate collection" do
51
- # jellies = @controller.send(:paginate_all_jellies)
52
- # assert_equal 2, jellies.total_pages
53
- # assert_equal 3, jellies.total_entries
54
- #end
55
-
50
+ should "paginate collection" do
51
+ jellies = @controller.send(:paginate_all_jellies)
52
+
53
+ assert_equal 4, jellies.total_pages, "10 jellies, 3 per page = 4 pages"
54
+ assert_equal 10, jellies.total_entries, "Confirm 10 total jellies"
55
+ end
56
56
 
57
57
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: crudify
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Spencer Steffen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-04 00:00:00 -08:00
13
+ date: 2011-03-05 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -25,39 +25,72 @@ dependencies:
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
- name: meta_search
28
+ name: will_paginate
29
29
  prerelease: false
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 1.0.1
35
+ version: 2.3.15
36
36
  type: :runtime
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
- name: shoulda
39
+ name: meta_search
40
40
  prerelease: false
41
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.1
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: shoulda
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
42
53
  none: false
43
54
  requirements:
44
55
  - - ">="
45
56
  - !ruby/object:Gem::Version
46
57
  version: 2.11.3
47
58
  type: :development
48
- version_requirements: *id003
59
+ version_requirements: *id004
49
60
  - !ruby/object:Gem::Dependency
50
61
  name: sqlite3-ruby
51
62
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
63
+ requirement: &id005 !ruby/object:Gem::Requirement
53
64
  none: false
54
65
  requirements:
55
66
  - - ">="
56
67
  - !ruby/object:Gem::Version
57
68
  version: 1.3.3
58
69
  type: :development
59
- version_requirements: *id004
60
- description: Crudify is a dynamic resource controller for Rails 3. The goal is to have very skinny controllers with powerful hooks to easily customize.
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: capybara
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.4.1
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: selenium-webdriver
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 0.1.3
91
+ type: :development
92
+ version_requirements: *id007
93
+ description: Crudify is a dynamic resource controller for Rails 3. The idea is skinny controllers with powerful hooks for easy customization.
61
94
  email:
62
95
  - spencer@citrusme.com
63
96
  executables: []
@@ -79,9 +112,60 @@ files:
79
112
  - lib/crudify/class_methods.rb
80
113
  - lib/crudify/hook_methods.rb
81
114
  - lib/crudify/version.rb
82
- - log/development.log
115
+ - test/dummy/Rakefile
116
+ - test/dummy/app/controllers/admin/peanut_butters_controller.rb
117
+ - test/dummy/app/controllers/application_controller.rb
118
+ - test/dummy/app/controllers/jellies_controller.rb
119
+ - test/dummy/app/models/jelly.rb
120
+ - test/dummy/app/models/peanut_butter.rb
121
+ - test/dummy/app/views/admin/peanut_butters/_fields.html.erb
122
+ - test/dummy/app/views/admin/peanut_butters/edit.html.erb
123
+ - test/dummy/app/views/admin/peanut_butters/index.html.erb
124
+ - test/dummy/app/views/admin/peanut_butters/new.html.erb
125
+ - test/dummy/app/views/admin/peanut_butters/show.html.erb
126
+ - test/dummy/app/views/jellies/_fields.html.erb
127
+ - test/dummy/app/views/jellies/edit.html.erb
128
+ - test/dummy/app/views/jellies/index.html.erb
129
+ - test/dummy/app/views/jellies/new.html.erb
130
+ - test/dummy/app/views/jellies/show.html.erb
131
+ - test/dummy/app/views/layouts/application.html.erb
132
+ - test/dummy/app/views/shared/_error_messages.html.erb
133
+ - test/dummy/config.ru
134
+ - test/dummy/config/application.rb
135
+ - test/dummy/config/boot.rb
136
+ - test/dummy/config/database.yml
137
+ - test/dummy/config/environment.rb
138
+ - test/dummy/config/environments/development.rb
139
+ - test/dummy/config/environments/production.rb
140
+ - test/dummy/config/environments/test.rb
141
+ - test/dummy/config/initializers/backtrace_silencers.rb
142
+ - test/dummy/config/initializers/green_eggs_and_spam.rb
143
+ - test/dummy/config/initializers/inflections.rb
144
+ - test/dummy/config/initializers/mime_types.rb
145
+ - test/dummy/config/initializers/secret_token.rb
146
+ - test/dummy/config/initializers/session_store.rb
147
+ - test/dummy/config/routes.rb
148
+ - test/dummy/db/migrate/20110223073415_create_jellies.rb
149
+ - test/dummy/db/migrate/20110223073427_create_peanut_butters.rb
150
+ - test/dummy/db/production.sqlite3
151
+ - test/dummy/db/schema.rb
152
+ - test/dummy/public/404.html
153
+ - test/dummy/public/422.html
154
+ - test/dummy/public/500.html
155
+ - test/dummy/public/favicon.ico
156
+ - test/dummy/public/javascripts/application.js
157
+ - test/dummy/public/javascripts/controls.js
158
+ - test/dummy/public/javascripts/dragdrop.js
159
+ - test/dummy/public/javascripts/effects.js
160
+ - test/dummy/public/javascripts/index.html
161
+ - test/dummy/public/javascripts/prototype.js
162
+ - test/dummy/public/javascripts/rails.js
163
+ - test/dummy/public/stylesheets/styles.css
164
+ - test/dummy/script/rails
165
+ - test/functional/jellies_controller_test.rb
83
166
  - test/helper.rb
84
- - test/test_controller.rb
167
+ - test/integration/demo_test.rb
168
+ - test/unit/crudify_test.rb
85
169
  has_rdoc: true
86
170
  homepage: http://github.com/citrus/crudify
87
171
  licenses: []
@@ -106,10 +190,62 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
190
  requirements: []
107
191
 
108
192
  rubyforge_project:
109
- rubygems_version: 1.5.0
193
+ rubygems_version: 1.6.0
110
194
  signing_key:
111
195
  specification_version: 3
112
196
  summary: Crudify is a dynamic resource controller for Rails 3.
113
197
  test_files:
198
+ - test/dummy/Rakefile
199
+ - test/dummy/app/controllers/admin/peanut_butters_controller.rb
200
+ - test/dummy/app/controllers/application_controller.rb
201
+ - test/dummy/app/controllers/jellies_controller.rb
202
+ - test/dummy/app/models/jelly.rb
203
+ - test/dummy/app/models/peanut_butter.rb
204
+ - test/dummy/app/views/admin/peanut_butters/_fields.html.erb
205
+ - test/dummy/app/views/admin/peanut_butters/edit.html.erb
206
+ - test/dummy/app/views/admin/peanut_butters/index.html.erb
207
+ - test/dummy/app/views/admin/peanut_butters/new.html.erb
208
+ - test/dummy/app/views/admin/peanut_butters/show.html.erb
209
+ - test/dummy/app/views/jellies/_fields.html.erb
210
+ - test/dummy/app/views/jellies/edit.html.erb
211
+ - test/dummy/app/views/jellies/index.html.erb
212
+ - test/dummy/app/views/jellies/new.html.erb
213
+ - test/dummy/app/views/jellies/show.html.erb
214
+ - test/dummy/app/views/layouts/application.html.erb
215
+ - test/dummy/app/views/shared/_error_messages.html.erb
216
+ - test/dummy/config.ru
217
+ - test/dummy/config/application.rb
218
+ - test/dummy/config/boot.rb
219
+ - test/dummy/config/database.yml
220
+ - test/dummy/config/environment.rb
221
+ - test/dummy/config/environments/development.rb
222
+ - test/dummy/config/environments/production.rb
223
+ - test/dummy/config/environments/test.rb
224
+ - test/dummy/config/initializers/backtrace_silencers.rb
225
+ - test/dummy/config/initializers/green_eggs_and_spam.rb
226
+ - test/dummy/config/initializers/inflections.rb
227
+ - test/dummy/config/initializers/mime_types.rb
228
+ - test/dummy/config/initializers/secret_token.rb
229
+ - test/dummy/config/initializers/session_store.rb
230
+ - test/dummy/config/routes.rb
231
+ - test/dummy/db/migrate/20110223073415_create_jellies.rb
232
+ - test/dummy/db/migrate/20110223073427_create_peanut_butters.rb
233
+ - test/dummy/db/production.sqlite3
234
+ - test/dummy/db/schema.rb
235
+ - test/dummy/public/404.html
236
+ - test/dummy/public/422.html
237
+ - test/dummy/public/500.html
238
+ - test/dummy/public/favicon.ico
239
+ - test/dummy/public/javascripts/application.js
240
+ - test/dummy/public/javascripts/controls.js
241
+ - test/dummy/public/javascripts/dragdrop.js
242
+ - test/dummy/public/javascripts/effects.js
243
+ - test/dummy/public/javascripts/index.html
244
+ - test/dummy/public/javascripts/prototype.js
245
+ - test/dummy/public/javascripts/rails.js
246
+ - test/dummy/public/stylesheets/styles.css
247
+ - test/dummy/script/rails
248
+ - test/functional/jellies_controller_test.rb
114
249
  - test/helper.rb
115
- - test/test_controller.rb
250
+ - test/integration/demo_test.rb
251
+ - test/unit/crudify_test.rb