Sha256: 1aa744fed036ae4b07ea96f83dd5b09972c8ea3c474730f0d25688b75fec9de9

Contents?: true

Size: 1.85 KB

Versions: 13

Compression:

Stored size: 1.85 KB

Contents

module Appstats
  class TestQuery

    attr_accessor :query, :query_to_sql, :group_query_to_sql

    def process_query
      query.query_to_sql = "select count(*) as num from appstats_test_objects"
      query.group_query_to_sql = "select context_key_filter, context_value_filter, count(*) as num from (select 'name' as context_key_filter, name as context_value_filter from appstats_test_objects) results group by context_value_filter"
    end
    
    def db_connection
      if query.host == "otherServer"
        dbconfig = YAML::load(File.open('db/config.yml'))
        ActiveRecord::Base.establish_connection(dbconfig['development']).connection
      else
        Appstats.connection
      end
    end
    
  end
  
  class BadTestQuery

    attr_accessor :query, :query_to_sql, :group_query_to_sql

    def process_query
      query.query_to_sql = "this is not valid sql"
    end
    
    def db_connection
      Appstats.connection
    end
    
  end

  class BadGroupTestQuery

    attr_accessor :query, :query_to_sql, :group_query_to_sql

    def process_query
      query.query_to_sql = "select count(*) as num from appstats_test_objects"
      query.group_query_to_sql = "this is not valid sql"
    end
    
    def db_connection
      Appstats.connection
    end
    
  end

  
  module Core
    class AnotherTestQuery
      attr_accessor :query
      def process_query; end
      def db_connection
        Appstats.connection
      end

    end
  end
  
  class InvalidTestQuery

    attr_accessor :query

    def process_query
      query.query_to_sql = "select * from appstats_test_objects"
      query.group_query_to_sql = "select * from appstats_test_objects"
    end


    def db_connection
      Appstats.connection
    end
    
  end
  
end


class YetAnotherTestQuery
  attr_accessor :query
  def process_query; end
  def db_connection
    Appstats.connection
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
appstats-0.25.1 lib/appstats/test_query.rb
appstats-0.25.0 lib/appstats/test_query.rb
appstats-0.24.0 lib/appstats/test_query.rb
appstats-0.23.5 lib/appstats/test_query.rb
appstats-0.23.4 lib/appstats/test_query.rb
appstats-0.23.3 lib/appstats/test_query.rb
appstats-0.23.2 lib/appstats/test_query.rb
appstats-0.23.1 lib/appstats/test_query.rb
appstats-0.23.0 lib/appstats/test_query.rb
appstats-0.22.6 lib/appstats/test_query.rb
appstats-0.22.5 lib/appstats/test_query.rb
appstats-0.22.4 lib/appstats/test_query.rb
appstats-0.22.3 lib/appstats/test_query.rb