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.
- data/README.rdoc +18 -14
- data/VERSION.yml +5 -0
- data/generators/scaffold_resource/templates/rspec/routing_spec.rb +8 -8
- data/generators/scaffold_resource/templates/rspec/views/index_spec.rb +2 -2
- data/lib/resource_controller.rb +5 -14
- data/lib/resource_controller/base.rb +2 -2
- data/lib/resource_controller/class_methods.rb +2 -2
- data/lib/resource_controller/controller.rb +3 -2
- data/lib/resource_controller/helpers.rb +0 -6
- data/lib/resource_controller/helpers/nested.rb +1 -1
- data/lib/resource_controller/singleton.rb +2 -2
- data/test/app/controllers/{application.rb → application_controller.rb} +0 -2
- data/test/app/controllers/cms/personnel_controller.rb +2 -0
- data/test/app/controllers/cms/photos_controller.rb +6 -0
- data/test/app/controllers/photos_controller.rb +1 -0
- data/test/app/models/personnel.rb +3 -0
- data/test/app/models/photo.rb +1 -0
- data/test/app/views/cms/photos/edit.rhtml +17 -0
- data/test/app/views/cms/photos/index.rhtml +20 -0
- data/test/app/views/cms/photos/new.rhtml +16 -0
- data/test/app/views/cms/photos/show.rhtml +8 -0
- data/test/config/boot.rb +6 -5
- data/test/config/database.yml +6 -10
- data/test/config/environment.rb +4 -4
- data/test/config/environments/development.rb +0 -4
- data/test/config/initializers/inflections.rb +14 -0
- data/test/config/routes.rb +3 -0
- data/test/db/migrate/013_create_personnel.rb +11 -0
- data/test/db/migrate/014_add_personnel_id_to_photos.rb +9 -0
- data/test/db/schema.rb +9 -3
- data/test/test/fixtures/personnel.yml +5 -0
- data/test/test/functional/cms/options_controller_test.rb +1 -1
- data/test/test/functional/cms/photos_controller_test.rb +43 -0
- data/test/test/functional/cms/products_controller_test.rb +1 -1
- data/test/test/functional/comments_controller_test.rb +2 -9
- data/test/test/functional/images_controller_test.rb +1 -8
- data/test/test/functional/people_controller_test.rb +2 -9
- data/test/test/functional/photos_controller_test.rb +2 -9
- data/test/test/functional/posts_controller_test.rb +2 -9
- data/test/test/functional/projects_controller_test.rb +12 -9
- data/test/test/functional/somethings_controller_test.rb +2 -9
- data/test/test/functional/tags_controller_test.rb +2 -9
- data/test/test/functional/users_controller_test.rb +2 -9
- data/test/test/test_helper.rb +4 -3
- data/test/test/unit/accessors_test.rb +2 -2
- data/test/test/unit/account_test.rb +1 -1
- data/test/test/unit/action_options_test.rb +1 -1
- data/test/test/unit/base_test.rb +1 -1
- data/test/test/unit/comment_test.rb +1 -1
- data/test/test/unit/failable_action_options_test.rb +1 -1
- data/test/test/unit/helpers_test.rb +1 -1
- data/test/test/unit/image_test.rb +1 -1
- data/test/test/unit/option_test.rb +1 -1
- data/test/test/unit/photo_test.rb +1 -1
- data/test/test/unit/post_test.rb +1 -1
- data/test/test/unit/project_test.rb +1 -1
- data/test/test/unit/response_collector_test.rb +1 -1
- data/test/test/unit/something_test.rb +1 -1
- data/test/test/unit/tag_test.rb +1 -1
- data/test/test/unit/urligence_test.rb +1 -1
- metadata +162 -122
- data/Rakefile +0 -35
- data/init.rb +0 -1
- data/lib/resource_controller/version.rb +0 -9
- data/test/log/development.log +0 -3350
- data/test/log/test.log +0 -174947
- data/test/log/thin.log +0 -12
- data/test/vendor/plugins/shoulda/Rakefile +0 -32
- data/test/vendor/plugins/shoulda/bin/convert_to_should_syntax +0 -40
- data/test/vendor/plugins/shoulda/init.rb +0 -3
- data/test/vendor/plugins/shoulda/lib/shoulda.rb +0 -43
- data/test/vendor/plugins/shoulda/lib/shoulda/active_record_helpers.rb +0 -580
- data/test/vendor/plugins/shoulda/lib/shoulda/color.rb +0 -77
- data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/controller_tests.rb +0 -467
- data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/html.rb +0 -201
- data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/xml.rb +0 -170
- data/test/vendor/plugins/shoulda/lib/shoulda/gem/proc_extensions.rb +0 -14
- data/test/vendor/plugins/shoulda/lib/shoulda/gem/shoulda.rb +0 -239
- data/test/vendor/plugins/shoulda/lib/shoulda/general.rb +0 -118
- data/test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb +0 -22
data/test/db/schema.rb
CHANGED
@@ -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
|
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
|
+
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|
|
@@ -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 <
|
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 <
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
@
|
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|
|
data/test/test/test_helper.rb
CHANGED
@@ -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
|
8
|
+
class ActiveSupport::TestCase
|
8
9
|
self.use_transactional_fixtures = true
|
9
10
|
self.use_instantiated_fixtures = false
|
10
|
-
|
11
|
-
|
11
|
+
|
12
|
+
fixtures :all
|
12
13
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__)+'/../test_helper'
|
2
2
|
|
3
|
-
class AccessorsTest <
|
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
|
data/test/test/unit/base_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__)+'/../test_helper'
|
2
2
|
|
3
|
-
class FailableActionOptionsTest <
|
3
|
+
class FailableActionOptionsTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
5
|
@controller = PostsController.new
|
6
6
|
@create = ResourceController::FailableActionOptions.new
|
data/test/test/unit/post_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__)+'/../test_helper'
|
2
2
|
|
3
|
-
class ResponseCollectorTest <
|
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
|