resource_controller 0.5.3 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/README.rdoc +18 -14
  2. data/VERSION.yml +5 -0
  3. data/generators/scaffold_resource/templates/rspec/routing_spec.rb +8 -8
  4. data/generators/scaffold_resource/templates/rspec/views/index_spec.rb +2 -2
  5. data/lib/resource_controller.rb +5 -14
  6. data/lib/resource_controller/base.rb +2 -2
  7. data/lib/resource_controller/class_methods.rb +2 -2
  8. data/lib/resource_controller/controller.rb +3 -2
  9. data/lib/resource_controller/helpers.rb +0 -6
  10. data/lib/resource_controller/helpers/nested.rb +1 -1
  11. data/lib/resource_controller/singleton.rb +2 -2
  12. data/test/app/controllers/{application.rb → application_controller.rb} +0 -2
  13. data/test/app/controllers/cms/personnel_controller.rb +2 -0
  14. data/test/app/controllers/cms/photos_controller.rb +6 -0
  15. data/test/app/controllers/photos_controller.rb +1 -0
  16. data/test/app/models/personnel.rb +3 -0
  17. data/test/app/models/photo.rb +1 -0
  18. data/test/app/views/cms/photos/edit.rhtml +17 -0
  19. data/test/app/views/cms/photos/index.rhtml +20 -0
  20. data/test/app/views/cms/photos/new.rhtml +16 -0
  21. data/test/app/views/cms/photos/show.rhtml +8 -0
  22. data/test/config/boot.rb +6 -5
  23. data/test/config/database.yml +6 -10
  24. data/test/config/environment.rb +4 -4
  25. data/test/config/environments/development.rb +0 -4
  26. data/test/config/initializers/inflections.rb +14 -0
  27. data/test/config/routes.rb +3 -0
  28. data/test/db/migrate/013_create_personnel.rb +11 -0
  29. data/test/db/migrate/014_add_personnel_id_to_photos.rb +9 -0
  30. data/test/db/schema.rb +9 -3
  31. data/test/test/fixtures/personnel.yml +5 -0
  32. data/test/test/functional/cms/options_controller_test.rb +1 -1
  33. data/test/test/functional/cms/photos_controller_test.rb +43 -0
  34. data/test/test/functional/cms/products_controller_test.rb +1 -1
  35. data/test/test/functional/comments_controller_test.rb +2 -9
  36. data/test/test/functional/images_controller_test.rb +1 -8
  37. data/test/test/functional/people_controller_test.rb +2 -9
  38. data/test/test/functional/photos_controller_test.rb +2 -9
  39. data/test/test/functional/posts_controller_test.rb +2 -9
  40. data/test/test/functional/projects_controller_test.rb +12 -9
  41. data/test/test/functional/somethings_controller_test.rb +2 -9
  42. data/test/test/functional/tags_controller_test.rb +2 -9
  43. data/test/test/functional/users_controller_test.rb +2 -9
  44. data/test/test/test_helper.rb +4 -3
  45. data/test/test/unit/accessors_test.rb +2 -2
  46. data/test/test/unit/account_test.rb +1 -1
  47. data/test/test/unit/action_options_test.rb +1 -1
  48. data/test/test/unit/base_test.rb +1 -1
  49. data/test/test/unit/comment_test.rb +1 -1
  50. data/test/test/unit/failable_action_options_test.rb +1 -1
  51. data/test/test/unit/helpers_test.rb +1 -1
  52. data/test/test/unit/image_test.rb +1 -1
  53. data/test/test/unit/option_test.rb +1 -1
  54. data/test/test/unit/photo_test.rb +1 -1
  55. data/test/test/unit/post_test.rb +1 -1
  56. data/test/test/unit/project_test.rb +1 -1
  57. data/test/test/unit/response_collector_test.rb +1 -1
  58. data/test/test/unit/something_test.rb +1 -1
  59. data/test/test/unit/tag_test.rb +1 -1
  60. data/test/test/unit/urligence_test.rb +1 -1
  61. metadata +162 -122
  62. data/Rakefile +0 -35
  63. data/init.rb +0 -1
  64. data/lib/resource_controller/version.rb +0 -9
  65. data/test/log/development.log +0 -3350
  66. data/test/log/test.log +0 -174947
  67. data/test/log/thin.log +0 -12
  68. data/test/vendor/plugins/shoulda/Rakefile +0 -32
  69. data/test/vendor/plugins/shoulda/bin/convert_to_should_syntax +0 -40
  70. data/test/vendor/plugins/shoulda/init.rb +0 -3
  71. data/test/vendor/plugins/shoulda/lib/shoulda.rb +0 -43
  72. data/test/vendor/plugins/shoulda/lib/shoulda/active_record_helpers.rb +0 -580
  73. data/test/vendor/plugins/shoulda/lib/shoulda/color.rb +0 -77
  74. data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/controller_tests.rb +0 -467
  75. data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/html.rb +0 -201
  76. data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/xml.rb +0 -170
  77. data/test/vendor/plugins/shoulda/lib/shoulda/gem/proc_extensions.rb +0 -14
  78. data/test/vendor/plugins/shoulda/lib/shoulda/gem/shoulda.rb +0 -239
  79. data/test/vendor/plugins/shoulda/lib/shoulda/general.rb +0 -118
  80. data/test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb +0 -22
@@ -0,0 +1,11 @@
1
+ class CreatePersonnel < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :personnel, :force => true do |t|
4
+ t.timestamps
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :personnel
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class AddPersonnelIdToPhotos < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :photos, :personnel_id, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :photos, :personnel_id
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated from the current state of the database. Instead of editing this file,
2
- # please use the migrations feature of ActiveRecord to incrementally modify your database, and
2
+ # please use the migrations feature of Active Record to incrementally modify your database, and
3
3
  # then regenerate this schema definition.
4
4
  #
5
5
  # Note that this schema.rb definition is the authoritative source for your database schema. If you need
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # It's strongly recommended to check this file into your version control system.
11
11
 
12
- ActiveRecord::Schema.define(:version => 12) do
12
+ ActiveRecord::Schema.define(:version => 14) do
13
13
 
14
14
  create_table "accounts", :force => true do |t|
15
15
  t.string "name"
@@ -33,9 +33,15 @@ ActiveRecord::Schema.define(:version => 12) do
33
33
  t.string "title"
34
34
  end
35
35
 
36
+ create_table "personnel", :force => true do |t|
37
+ t.datetime "created_at"
38
+ t.datetime "updated_at"
39
+ end
40
+
36
41
  create_table "photos", :force => true do |t|
37
42
  t.string "title"
38
43
  t.integer "account_id"
44
+ t.integer "personnel_id"
39
45
  end
40
46
 
41
47
  create_table "photos_tags", :force => true do |t|
@@ -45,7 +51,7 @@ ActiveRecord::Schema.define(:version => 12) do
45
51
 
46
52
  create_table "posts", :force => true do |t|
47
53
  t.string "title", :default => ""
48
- t.text "body"
54
+ t.text "body", :default => ""
49
55
  end
50
56
 
51
57
  create_table "products", :force => true do |t|
@@ -0,0 +1,5 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ one:
3
+ id: 1
4
+ two:
5
+ id: 2
@@ -4,7 +4,7 @@ require 'cms/options_controller'
4
4
  # Re-raise errors caught by the controller.
5
5
  class Cms::OptionsController; def rescue_action(e) raise e end; end
6
6
 
7
- class Cms::OptionsControllerTest < Test::Unit::TestCase
7
+ class Cms::OptionsControllerTest < ActionController::TestCase
8
8
  def setup
9
9
  @controller = Cms::OptionsController.new
10
10
  @request = ActionController::TestRequest.new
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+ require 'cms/photos_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class Cms::PhotosController; def rescue_action(e) raise e end; end
6
+
7
+ class Cms::PhotosControllerTest < ActionController::TestCase
8
+ def setup
9
+ @controller = Cms::PhotosController.new
10
+ @request = ActionController::TestRequest.new
11
+ @response = ActionController::TestResponse.new
12
+ @photo = Photo.find 1
13
+ end
14
+
15
+ context "with personnel as parent" do
16
+ context "on get to :index" do
17
+ setup do
18
+ get :index, :personnel_id => 1
19
+ end
20
+
21
+ should_respond_with :success
22
+ should_render_template "index"
23
+ should_assign_to :photos
24
+ should_assign_to :personnel
25
+ should "scope photos to personnel" do
26
+ assert assigns(:photos).all? { |photo| photo.personnel.id == 1 }
27
+ end
28
+ end
29
+
30
+ context "on post to :create" do
31
+ setup do
32
+ post :create, :personnel_id => 1, :photo => {}
33
+ end
34
+
35
+ should_redirect_to 'cms_personnel_photo_path(@photo.personnel, @photo)'
36
+ should_assign_to :photo
37
+ should_assign_to :personnel
38
+ should "scope photo to personel" do
39
+ assert personnel(:one), assigns(:photo).personnel
40
+ end
41
+ end
42
+ end
43
+ end
@@ -4,7 +4,7 @@ require 'cms/products_controller'
4
4
  # Re-raise errors caught by the controller.
5
5
  class Cms::ProductsController; def rescue_action(e) raise e end; end
6
6
 
7
- class Cms::ProductsControllerTest < Test::Unit::TestCase
7
+ class Cms::ProductsControllerTest < ActionController::TestCase
8
8
  def setup
9
9
  @controller = Cms::ProductsController.new
10
10
  @request = ActionController::TestRequest.new
@@ -1,15 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'comments_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class CommentsController; def rescue_action(e) raise e end; end
6
-
7
- class CommentsControllerTest < Test::Unit::TestCase
3
+ class CommentsControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = CommentsController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @comment = Comment.find 1
5
+ @comment = Comment.find 1
13
6
  end
14
7
 
15
8
  context "with parent post" do
@@ -1,14 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'images_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class ImagesController; def rescue_action(e) raise e end; end
6
-
7
- class ImagesControllerTest < Test::Unit::TestCase
3
+ class ImagesControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = ImagesController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
5
  @image = images :one
13
6
  end
14
7
 
@@ -1,15 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'people_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class PeopleController; def rescue_action(e) raise e end; end
6
-
7
- class PeopleControllerTest < Test::Unit::TestCase
3
+ class PeopleControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = PeopleController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @person = accounts :one
5
+ @person = accounts :one
13
6
  end
14
7
 
15
8
  should_be_restful do |resource|
@@ -1,15 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'photos_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class PhotosController; def rescue_action(e) raise e end; end
6
-
7
- class PhotosControllerTest < Test::Unit::TestCase
3
+ class PhotosControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = PhotosController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @photo = Photo.find 1
5
+ @photo = Photo.find 1
13
6
  end
14
7
 
15
8
  context "actions specified" do
@@ -1,15 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'posts_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class PostsController; def rescue_action(e) raise e end; end
6
-
7
- class PostsControllerTest < Test::Unit::TestCase
3
+ class PostsControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = PostsController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @post = Post.find 1
5
+ @post = Post.find 1
13
6
  end
14
7
 
15
8
  should_be_restful do |resource|
@@ -1,18 +1,21 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'projects_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class ProjectsController; def rescue_action(e) raise e end; end
6
-
7
- class ProjectsControllerTest < Test::Unit::TestCase
3
+ class ProjectsControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = ProjectsController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @project = projects :one
5
+ @project = projects :one
13
6
  end
14
7
 
15
8
  should_be_restful do |resource|
16
9
  resource.formats = [:html]
17
10
  end
11
+
12
+ context "on DELETE to :destroy that fails" do
13
+ setup do
14
+ Project.any_instance.stubs(:destroy).returns(false)
15
+ delete :destroy, :id => @project.to_param
16
+ end
17
+
18
+ should_respond_with :redirect
19
+ should_redirect_to "project_url(@project)"
20
+ end
18
21
  end
@@ -1,15 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'somethings_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class SomethingsController; def rescue_action(e) raise e end; end
6
-
7
- class SomethingsControllerTest < Test::Unit::TestCase
3
+ class SomethingsControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = SomethingsController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @something = somethings :one
5
+ @something = somethings :one
13
6
  end
14
7
 
15
8
  context "actions specified" do
@@ -1,15 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'tags_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class TagsController; def rescue_action(e) raise e end; end
6
-
7
- class TagsControllerTest < Test::Unit::TestCase
3
+ class TagsControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = TagsController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @tag = Tag.find 1
5
+ @tag = Tag.find 1
13
6
  end
14
7
 
15
8
  context "with photo as parent" do
@@ -1,15 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
- require 'users_controller'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class UsersController; def rescue_action(e) raise e end; end
6
-
7
- class UsersControllerTest < Test::Unit::TestCase
3
+ class UsersControllerTest < ActionController::TestCase
8
4
  def setup
9
- @controller = UsersController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- @dude = accounts :one
5
+ @dude = accounts :one
13
6
  end
14
7
 
15
8
  should_be_restful do |resource|
@@ -1,12 +1,13 @@
1
1
  $:.reject! { |path| path.include? 'TextMate' }
2
+ require 'test/unit'
2
3
  ENV["RAILS_ENV"] = "test"
3
4
  require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
4
5
  require 'test_help'
5
6
  require 'mocha'
6
7
 
7
- class Test::Unit::TestCase
8
+ class ActiveSupport::TestCase
8
9
  self.use_transactional_fixtures = true
9
10
  self.use_instantiated_fixtures = false
10
-
11
- load_all_fixtures
11
+
12
+ fixtures :all
12
13
  end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__)+'/../test_helper'
2
2
 
3
- class AccessorsTest < Test::Unit::TestCase
3
+ class AccessorsTest < ActiveSupport::TestCase
4
4
  def setup
5
5
  PostsController.class_eval do
6
6
  extend ResourceController::Accessors
@@ -107,4 +107,4 @@ class AccessorsTest < Test::Unit::TestCase
107
107
  end
108
108
  end
109
109
 
110
- end
110
+ end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class PersonTest < Test::Unit::TestCase
3
+ class PersonTest < ActiveSupport::TestCase
4
4
  def test_truth
5
5
  assert true
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__)+'/../test_helper'
2
2
 
3
- class ActionOptionsTest < Test::Unit::TestCase
3
+ class ActionOptionsTest < ActiveSupport::TestCase
4
4
  def setup
5
5
  @controller = PostsController.new
6
6
  @create = ResourceController::ActionOptions.new
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__)+'/../test_helper'
2
2
 
3
- class BaseTest < Test::Unit::TestCase
3
+ class BaseTest < ActiveSupport::TestCase
4
4
  def setup
5
5
  @controller = ResourceController::Base.new
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class CommentTest < Test::Unit::TestCase
3
+ class CommentTest < ActiveSupport::TestCase
4
4
  fixtures :comments
5
5
 
6
6
  # Replace this with your real tests.
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__)+'/../test_helper'
2
2
 
3
- class FailableActionOptionsTest < Test::Unit::TestCase
3
+ class FailableActionOptionsTest < ActiveSupport::TestCase
4
4
  def setup
5
5
  @controller = PostsController.new
6
6
  @create = ResourceController::FailableActionOptions.new
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__)+'/../test_helper'
2
2
 
3
- class HelpersTest < Test::Unit::TestCase
3
+ class HelpersTest < ActiveSupport::TestCase
4
4
 
5
5
  def setup
6
6
  @controller = PostsController.new
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class ImageTest < Test::Unit::TestCase
3
+ class ImageTest < ActiveSupport::TestCase
4
4
  def test_truth
5
5
  assert true
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class OptionTest < Test::Unit::TestCase
3
+ class OptionTest < ActiveSupport::TestCase
4
4
  fixtures :options
5
5
 
6
6
  # Replace this with your real tests.
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class PhotoTest < Test::Unit::TestCase
3
+ class PhotoTest < ActiveSupport::TestCase
4
4
  fixtures :photos
5
5
 
6
6
  # Replace this with your real tests.
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class PostTest < Test::Unit::TestCase
3
+ class PostTest < ActiveSupport::TestCase
4
4
  fixtures :posts
5
5
 
6
6
  # Replace this with your real tests.
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class ProjectTest < Test::Unit::TestCase
3
+ class ProjectTest < ActiveSupport::TestCase
4
4
  fixtures :projects
5
5
 
6
6
  # Replace this with your real tests.
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__)+'/../test_helper'
2
2
 
3
- class ResponseCollectorTest < Test::Unit::TestCase
3
+ class ResponseCollectorTest < ActiveSupport::TestCase
4
4
  context "yielding a block to a collector object" do
5
5
  setup do
6
6
  @collector = ResourceController::ResponseCollector.new