inherited_resources 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,15 +12,15 @@ http://akitaonrails.com/2009/09/01/screencast-real-thin-restful-controllers-with
12
12
 
13
13
  == Rails 3
14
14
 
15
- Inherited Resources master branch is now supports Rails 3 and is backward incompatible.
15
+ Inherited Resources master branch is now supports Rails 3 and is NOT backward compatible.
16
16
 
17
17
  You can install it as:
18
18
 
19
- sudo gem install inherited_resources --version=1.1.pre
19
+ sudo gem install inherited_resources --version=1.1.1
20
20
 
21
21
  If you want to use the Rails 2.3.x version, you should install:
22
22
 
23
- sudo gem install inherited_resources --version=1.0
23
+ sudo gem install inherited_resources --version=1.0.6
24
24
 
25
25
  Or checkout from the v1.0 branch:
26
26
 
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  require 'jeweler'
10
10
  Jeweler::Tasks.new do |s|
11
11
  s.name = "inherited_resources"
12
- s.version = InheritedResources::VERSION
12
+ s.version = InheritedResources::VERSION.dup
13
13
  s.rubyforge_project = "inherited_resources"
14
14
  s.summary = "Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important."
15
15
  s.email = "jose.valim@gmail.com"
@@ -17,8 +17,8 @@ begin
17
17
  s.description = "Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important."
18
18
  s.authors = ['José Valim']
19
19
  s.files = FileList["[A-Z]*", "init.rb", "{lib}/**/*"]
20
- s.add_dependency("responders", "~> 0.5.0")
21
- s.add_dependency("has_scope", "~> 0.4.2")
20
+ s.add_dependency("responders", "~> 0.6.0")
21
+ s.add_dependency("has_scope", "~> 0.5.0")
22
22
  end
23
23
 
24
24
  Jeweler::GemcutterTasks.new
@@ -1,4 +1,4 @@
1
- require 'generators/rails/scaffold_controller/scaffold_controller_generator'
1
+ require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
2
2
 
3
3
  module Rails
4
4
  module Generators
@@ -20,7 +20,7 @@ module InheritedResources
20
20
  end
21
21
 
22
22
  class Railtie < ::Rails::Railtie
23
- railtie_name :inherited_resources
23
+ config.inherited_resources = InheritedResources
24
24
  config.generators.scaffold_controller = :inherited_resources_controller
25
25
  end
26
26
  end
@@ -3,26 +3,26 @@ module InheritedResources
3
3
  module Actions
4
4
 
5
5
  # GET /resources
6
- def index(&block)
7
- respond_with(*with_chain(collection), &block)
6
+ def index(options={}, &block)
7
+ respond_with(*(with_chain(collection) << options), &block)
8
8
  end
9
9
  alias :index! :index
10
10
 
11
11
  # GET /resources/1
12
- def show(&block)
13
- respond_with(*with_chain(resource), &block)
12
+ def show(options={}, &block)
13
+ respond_with(*(with_chain(resource) << options), &block)
14
14
  end
15
15
  alias :show! :show
16
16
 
17
17
  # GET /resources/new
18
- def new(&block)
19
- respond_with(*with_chain(build_resource), &block)
18
+ def new(options={}, &block)
19
+ respond_with(*(with_chain(build_resource) << options), &block)
20
20
  end
21
21
  alias :new! :new
22
22
 
23
23
  # GET /resources/1/edit
24
- def edit(&block)
25
- respond_with(*with_chain(resource), &block)
24
+ def edit(options={}, &block)
25
+ respond_with(*(with_chain(resource) << options), &block)
26
26
  end
27
27
  alias :edit! :edit
28
28
 
@@ -1,3 +1,3 @@
1
1
  module InheritedResources
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.2'.freeze
3
3
  end
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  class UsersController < AccountsController
11
11
  respond_to :html, :xml
12
+ respond_to :js, :only => [:create, :update, :destroy]
12
13
  attr_reader :scopes_applied
13
14
 
14
15
  protected
@@ -163,6 +164,12 @@ class CreateActionBaseTest < ActionController::TestCase
163
164
  assert_equal flash[:notice], 'User was successfully created.'
164
165
  end
165
166
 
167
+ def test_show_flash_message_with_javascript_request_when_success
168
+ User.stubs(:new).returns(mock_user(:save => true))
169
+ post :create, :format => :js
170
+ assert_equal flash[:notice], 'User was successfully created.'
171
+ end
172
+
166
173
  def test_render_new_template_when_user_cannot_be_saved
167
174
  User.stubs(:new).returns(mock_user(:save => false, :errors => {:some => :error}))
168
175
  post :create
@@ -200,6 +207,12 @@ class UpdateActionBaseTest < ActionController::TestCase
200
207
  assert_equal flash[:notice], 'User was successfully updated.'
201
208
  end
202
209
 
210
+ def test_show_flash_message_with_javascript_request_when_success
211
+ User.stubs(:find).returns(mock_user(:update_attributes => true))
212
+ post :update, :format => :js
213
+ assert_equal flash[:notice], 'User was successfully updated.'
214
+ end
215
+
203
216
  def test_render_edit_template_when_user_cannot_be_saved
204
217
  User.stubs(:find).returns(mock_user(:update_attributes => false, :errors => {:some => :error}))
205
218
  put :update
@@ -230,12 +243,24 @@ class DestroyActionBaseTest < ActionController::TestCase
230
243
  assert_equal flash[:notice], 'User was successfully destroyed.'
231
244
  end
232
245
 
233
- def test_show_flash_message_when_cannot_be_deleted
246
+ def test_show_flash_message_with_javascript_request_when_user_can_be_deleted
247
+ User.stubs(:find).returns(mock_user(:destroy => true))
248
+ delete :destroy, :format => :js
249
+ assert_equal flash[:notice], 'User was successfully destroyed.'
250
+ end
251
+
252
+ def test_show_flash_message_when_user_cannot_be_deleted
234
253
  User.stubs(:find).returns(mock_user(:destroy => false, :errors => { :fail => true }))
235
254
  delete :destroy
236
255
  assert_equal flash[:alert], 'User could not be destroyed.'
237
256
  end
238
257
 
258
+ def test_show_flash_message_with_javascript_request_when_user_cannot_be_deleted
259
+ User.stubs(:find).returns(mock_user(:destroy => false, :errors => { :fail => true }))
260
+ delete :destroy, :format => :js
261
+ assert_equal flash[:alert], 'User could not be destroyed.'
262
+ end
263
+
239
264
  def test_redirects_to_users_list
240
265
  User.stubs(:find).returns(mock_user(:destroy => true))
241
266
  @controller.expects(:collection_url).returns('http://test.host/')
@@ -1,5 +1,11 @@
1
1
  require 'rubygems'
2
2
 
3
+ gem 'responders', '0.6.0'
4
+ gem 'activesupport', '3.0.0.beta2'
5
+ gem 'activemodel', '3.0.0.beta2'
6
+ gem 'actionpack', '3.0.0.beta2'
7
+ gem 'railties', '3.0.0.beta2'
8
+
3
9
  begin
4
10
  gem "test-unit"
5
11
  rescue LoadError
@@ -36,6 +42,16 @@ require_dependency 'inherited_resources'
36
42
 
37
43
  ActionController::Base.view_paths = File.join(File.dirname(__FILE__), 'views')
38
44
 
39
- ActionController::Routing::Routes.draw do |map|
45
+ InheritedResources::Routes = ActionDispatch::Routing::RouteSet.new
46
+ InheritedResources::Routes.draw do |map|
40
47
  map.connect ':controller/:action/:id'
48
+ map.connect ':controller/:action'
49
+ end
50
+
51
+ ActionController::Base.send :include, InheritedResources::Routes.url_helpers
52
+
53
+ class ActiveSupport::TestCase
54
+ setup do
55
+ @routes = InheritedResources::Routes
56
+ end
41
57
  end
@@ -325,7 +325,7 @@ class UrlHelpersTest < ActiveSupport::TestCase
325
325
 
326
326
  new_bed = Bed.new
327
327
  Bed.stubs(:new).returns(new_bed)
328
- new_bed.stubs(:new_record?).returns(true)
328
+ new_bed.stubs(:persisted?).returns(false)
329
329
 
330
330
  controller = BedsController.new
331
331
  controller.instance_variable_set('@parent_type', :house)
@@ -379,7 +379,7 @@ class UrlHelpersTest < ActiveSupport::TestCase
379
379
 
380
380
  new_desk = Desk.new
381
381
  Desk.stubs(:new).returns(new_desk)
382
- new_desk.stubs(:new_record?).returns(true)
382
+ new_desk.stubs(:persisted?).returns(false)
383
383
 
384
384
  controller = Admin::DesksController.new
385
385
  controller.instance_variable_set('@parent_type', :house)
@@ -434,7 +434,7 @@ class UrlHelpersTest < ActiveSupport::TestCase
434
434
 
435
435
  new_dish = Dish.new
436
436
  Dish.stubs(:new).returns(new_dish)
437
- new_dish.stubs(:new_record?).returns(true)
437
+ new_dish.stubs(:persisted?).returns(false)
438
438
 
439
439
  controller = DishesController.new
440
440
  controller.instance_variable_set('@parent_type', :table)
@@ -533,7 +533,7 @@ class UrlHelpersTest < ActiveSupport::TestCase
533
533
  bed = Bed.new
534
534
  new_bed = Bed.new
535
535
  Bed.stubs(:new).returns(new_bed)
536
- new_bed.stubs(:new_record?).returns(true)
536
+ new_bed.stubs(:persisted?).returns(false)
537
537
 
538
538
  controller = BedsController.new
539
539
  controller.instance_variable_set('@parent_type', nil)
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inherited_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 2
9
+ version: 1.1.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - "Jos\xC3\xA9 Valim"
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-07 00:00:00 +01:00
17
+ date: 2010-04-03 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: responders
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ~>
22
26
  - !ruby/object:Gem::Version
23
- version: 0.5.0
24
- version:
27
+ segments:
28
+ - 0
29
+ - 6
30
+ - 0
31
+ version: 0.6.0
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: has_scope
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ~>
32
40
  - !ruby/object:Gem::Version
33
- version: 0.4.2
34
- version:
41
+ segments:
42
+ - 0
43
+ - 5
44
+ - 0
45
+ version: 0.5.0
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  description: Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important.
36
49
  email: jose.valim@gmail.com
37
50
  executables: []
@@ -74,18 +87,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
87
  requirements:
75
88
  - - ">="
76
89
  - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
77
92
  version: "0"
78
- version:
79
93
  required_rubygems_version: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - ">="
82
96
  - !ruby/object:Gem::Version
97
+ segments:
98
+ - 0
83
99
  version: "0"
84
- version:
85
100
  requirements: []
86
101
 
87
102
  rubyforge_project: inherited_resources
88
- rubygems_version: 1.3.5
103
+ rubygems_version: 1.3.6
89
104
  signing_key:
90
105
  specification_version: 3
91
106
  summary: Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important.