-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from haines/inherit_security
Inherit method security and test against Rails 3.x
- Loading branch information
Showing
34 changed files
with
297 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rake/testtask' | ||
|
||
test_task = if Rails.version.to_f < 3.2 | ||
require 'rails/test_unit/railtie' | ||
Rake::TestTask | ||
else | ||
require 'rails/test_unit/sub_test_task' | ||
Rails::SubTestTask | ||
end | ||
|
||
namespace :test do | ||
test_task.new(:decorators => "test:prepare") do |t| | ||
t.libs << "test" | ||
t.pattern = "test/decorators/**/*_test.rb" | ||
end | ||
end | ||
|
||
if Rake::Task.task_defined?('test:run') | ||
Rake::Task['test:run'].enhance do | ||
Rake::Task['test:decorators'].invoke | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,6 @@ | ||
require 'minitest/rails/active_support' | ||
|
||
module Draper | ||
module MiniTest | ||
|
||
class DecoratorTestCase < ::MiniTest::Rails::ActiveSupport::TestCase | ||
include Draper::ViewHelpers::ClassMethods | ||
alias_method :helper, :helpers | ||
|
||
register_spec_type(self) do |desc| | ||
desc < Draper::Decorator if desc.is_a?(Class) | ||
end | ||
register_spec_type(/Decorator( ?Test)?\z/i, self) | ||
end | ||
|
||
class Railtie < Rails::Railtie | ||
config.after_initialize do |app| | ||
if defined?(Capybara) | ||
require 'capybara/rspec/matchers' | ||
DecoratorTestCase.send :include, Capybara::RSpecMatchers | ||
end | ||
|
||
if defined?(Devise) | ||
require 'draper/test/devise_helper' | ||
DecoratorTestCase.send :include, Draper::DeviseHelper | ||
end | ||
end | ||
end | ||
class Draper::TestCase | ||
register_spec_type(self) do |desc| | ||
desc < Draper::Decorator || desc < Draper::CollectionDecorator if desc.is_a?(Class) | ||
end | ||
|
||
register_spec_type(/Decorator( ?Test)?\z/i, self) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,12 @@ | ||
module Draper | ||
module RSpec | ||
module DecoratorExampleGroup | ||
include Draper::TestCase::Behavior | ||
extend ActiveSupport::Concern | ||
|
||
module DecoratorExampleGroup | ||
extend ActiveSupport::Concern | ||
included { metadata[:type] = :decorator } | ||
|
||
include Draper::ViewHelpers::ClassMethods | ||
alias_method :helper, :helpers | ||
end | ||
|
||
::RSpec.configure do |config| | ||
# Automatically tag specs in specs/decorators as type: :decorator | ||
config.include DecoratorExampleGroup, :type => :decorator, :example_group => { | ||
:file_path => %r{spec/decorators} | ||
} | ||
end | ||
|
||
class Railtie < Rails::Railtie | ||
config.after_initialize do |app| | ||
::RSpec.configure do |rspec| | ||
if defined?(Capybara) | ||
require 'capybara/rspec/matchers' | ||
rspec.include Capybara::RSpecMatchers, :type => :decorator | ||
end | ||
|
||
if defined?(Devise) | ||
require 'draper/test/devise_helper' | ||
rspec.include Draper::DeviseHelper, :type => :decorator | ||
end | ||
end | ||
end | ||
end | ||
included { metadata[:type] = :decorator } | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.include DecoratorExampleGroup, example_group: {file_path: %r{spec/decorators}}, type: :decorator | ||
end | ||
end | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Draper | ||
begin | ||
require 'minitest/rails' | ||
rescue LoadError | ||
end | ||
|
||
active_support_test_case = begin | ||
require 'minitest/rails/active_support' # minitest-rails < 0.5 | ||
::MiniTest::Rails::ActiveSupport::TestCase | ||
rescue LoadError | ||
require 'active_support/test_case' | ||
::ActiveSupport::TestCase | ||
end | ||
|
||
class TestCase < active_support_test_case | ||
module Behavior | ||
if defined?(::Devise) | ||
require 'draper/test/devise_helper' | ||
include Draper::DeviseHelper | ||
end | ||
|
||
if defined?(::Capybara) && (defined?(::RSpec) || defined?(::MiniTest::Matchers)) | ||
require 'capybara/rspec/matchers' | ||
include ::Capybara::RSpecMatchers | ||
end | ||
|
||
include Draper::ViewHelpers::ClassMethods | ||
alias_method :helper, :helpers | ||
end | ||
|
||
include Behavior | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require 'test_helper' | ||
|
||
class <%= class_name %>DecoratorTest < ActiveSupport::TestCase | ||
class <%= class_name %>DecoratorTest < Draper::TestCase | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.