Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Get rid of a module to get specs passing

- This may...or may not be a good idea
  • Loading branch information...
commit c1de85093226994f5dae89a3fac101a04624c7db 1 parent a69afb0
chargify-pair authored June 28, 2012
4  lib/acts_as_revisable/base.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'acts_as_revisable/options'
2  
-require 'acts_as_revisable/quoted_columns'
3 2
 require 'acts_as_revisable/validations'
4 3
 require 'acts_as_revisable/acts/common'
5 4
 require 'acts_as_revisable/acts/revision'
@@ -44,10 +43,9 @@ class << self
44 43
           end
45 44
           options = args.extract_options!
46 45
           self.revisable_options = Options.new(options, &block)
47  
-          
  46
+
48 47
           self.send(:include, Common)
49 48
           self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?
50  
-          self.send(:include, WithoutScope::QuotedColumnConditions)
51 49
         end
52 50
     end
53 51
   end
31  lib/acts_as_revisable/quoted_columns.rb
... ...
@@ -1,31 +0,0 @@
1  
-# This module is more about the pretty than anything else. This allows
2  
-# you to use symbols for column names in a conditions hash.
3  
-#
4  
-#   User.find(:all, :conditions => ["? = ?", :name, "sam"])
5  
-# 
6  
-# Would generate:
7  
-# 
8  
-#   select * from users where "users"."name" = 'sam'
9  
-# 
10  
-# This is consistent with Rails and Ruby where symbols are used to
11  
-# represent methods. Only a symbol matching a column name will 
12  
-# trigger this beavior.
13  
-module WithoutScope::QuotedColumnConditions
14  
-  def self.included(base)
15  
-    base.send(:extend, ClassMethods)
16  
-  end
17  
-  
18  
-  module ClassMethods
19  
-    def quote_bound_value(value, c = connection)
20  
-      if value.is_a?(Symbol) && column_names.member?(value.to_s)
21  
-        # code borrowed from sanitize_sql_hash_for_conditions
22  
-        attr = value.to_s
23  
-        table_name = quoted_table_name
24  
-        
25  
-        return "#{table_name}.#{c.quote_column_name(attr)}"
26  
-      end
27  
-      
28  
-      super(value, c)
29  
-    end
30  
-  end
31  
-end
19  spec/acts_as_revisable/quoted_columns_spec.rb
... ...
@@ -1,19 +0,0 @@
1  
-require 'spec_helper'
2  
-
3  
-describe "the quoted_columns extension" do      
4  
-  after(:each) do
5  
-    cleanup_db
6  
-  end
7  
-  
8  
-  it "should quote symbols matching column names as columns" do
9  
-    Project.send(:quote_bound_value, :name).should == %q{"projects"."name"}
10  
-  end
11  
-  
12  
-  it "should not quote symbols that don't match column names" do
13  
-    Project.send(:quote_bound_value, :whatever).should == "'#{:whatever.to_yaml}'"
14  
-  end
15  
-  
16  
-  it "should not quote strings any differently" do
17  
-    Project.send(:quote_bound_value, "what").should == ActiveRecord::Base.send(:quote_bound_value, "what")
18  
-  end  
19  
-end

0 notes on commit c1de850

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