Skip to content
This repository
Browse code

Don't define methods in shoulda contexts

  • Loading branch information...
commit e64021e9755303ff7dc7d45ac908e65784a55e89 1 parent f7284b9
Joshua Clayton authored March 02, 2012 sikachu committed March 02, 2012

Showing 1 changed file with 19 additions and 16 deletions. Show diff stats Hide diff stats

  1. 35  test/storage/s3_test.rb
35  test/storage/s3_test.rb
@@ -350,24 +350,27 @@ def counter
350 350
   end
351 351
 
352 352
   context "Generating a secure url with an expiration" do
353  
-    def build_model_with_options(options = {})
354  
-      base_options = {
355  
-        :storage => :s3,
356  
-        :s3_credentials => {
357  
-          :production   => { :bucket => "prod_bucket" },
358  
-          :development  => { :bucket => "dev_bucket" }
359  
-        },
360  
-        :s3_host_alias => "something.something.com",
361  
-        :s3_permissions => "private",
362  
-        :path => ":attachment/:basename.:extension",
363  
-        :url => ":s3_alias_url"
364  
-      }
  353
+    setup do
  354
+      @build_model_with_options = lambda {|options|
  355
+        options ||= {}
  356
+        base_options = {
  357
+          :storage => :s3,
  358
+          :s3_credentials => {
  359
+            :production   => { :bucket => "prod_bucket" },
  360
+            :development  => { :bucket => "dev_bucket" }
  361
+          },
  362
+          :s3_host_alias => "something.something.com",
  363
+          :s3_permissions => "private",
  364
+          :path => ":attachment/:basename.:extension",
  365
+          :url => ":s3_alias_url"
  366
+        }
365 367
 
366  
-      rebuild_model base_options.merge(options)
  368
+        rebuild_model base_options.merge(options)
  369
+      }
367 370
     end
368 371
 
369 372
     should "use default options" do
370  
-      build_model_with_options
  373
+      @build_model_with_options[{}]
371 374
 
372 375
       rails_env("production")
373 376
 
@@ -382,7 +385,7 @@ def build_model_with_options(options = {})
382 385
     end
383 386
 
384 387
     should "allow overriding s3_url_options" do
385  
-      build_model_with_options :s3_url_options => { :response_content_disposition => "inline" }
  388
+      @build_model_with_options[:s3_url_options => { :response_content_disposition => "inline" }]
386 389
 
387 390
       rails_env("production")
388 391
 
@@ -397,7 +400,7 @@ def build_model_with_options(options = {})
397 400
     end
398 401
 
399 402
     should "allow overriding s3_object options with a proc" do
400  
-      build_model_with_options :s3_url_options => lambda {|attachment| { :response_content_type => attachment.avatar_content_type } }
  403
+      @build_model_with_options[:s3_url_options => lambda {|attachment| { :response_content_type => attachment.avatar_content_type } }]
401 404
 
402 405
       rails_env("production")
403 406
 

0 notes on commit e64021e

Please sign in to comment.
Something went wrong with that request. Please try again.