Commit e64021e9 by Joshua Clayton Committed by Prem Sichanugrist

Don't define methods in shoulda contexts

parent f7284b9e
...@@ -350,24 +350,27 @@ class S3Test < Test::Unit::TestCase ...@@ -350,24 +350,27 @@ class S3Test < Test::Unit::TestCase
end end
context "Generating a secure url with an expiration" do context "Generating a secure url with an expiration" do
def build_model_with_options(options = {}) setup do
base_options = { @build_model_with_options = lambda {|options|
:storage => :s3, options ||= {}
:s3_credentials => { base_options = {
:production => { :bucket => "prod_bucket" }, :storage => :s3,
:development => { :bucket => "dev_bucket" } :s3_credentials => {
}, :production => { :bucket => "prod_bucket" },
:s3_host_alias => "something.something.com", :development => { :bucket => "dev_bucket" }
:s3_permissions => "private", },
:path => ":attachment/:basename.:extension", :s3_host_alias => "something.something.com",
:url => ":s3_alias_url" :s3_permissions => "private",
} :path => ":attachment/:basename.:extension",
:url => ":s3_alias_url"
}
rebuild_model base_options.merge(options) rebuild_model base_options.merge(options)
}
end end
should "use default options" do should "use default options" do
build_model_with_options @build_model_with_options[{}]
rails_env("production") rails_env("production")
...@@ -382,7 +385,7 @@ class S3Test < Test::Unit::TestCase ...@@ -382,7 +385,7 @@ class S3Test < Test::Unit::TestCase
end end
should "allow overriding s3_url_options" do should "allow overriding s3_url_options" do
build_model_with_options :s3_url_options => { :response_content_disposition => "inline" } @build_model_with_options[:s3_url_options => { :response_content_disposition => "inline" }]
rails_env("production") rails_env("production")
...@@ -397,7 +400,7 @@ class S3Test < Test::Unit::TestCase ...@@ -397,7 +400,7 @@ class S3Test < Test::Unit::TestCase
end end
should "allow overriding s3_object options with a proc" do should "allow overriding s3_object options with a proc" do
build_model_with_options :s3_url_options => lambda {|attachment| { :response_content_type => attachment.avatar_content_type } } @build_model_with_options[:s3_url_options => lambda {|attachment| { :response_content_type => attachment.avatar_content_type } }]
rails_env("production") rails_env("production")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment