Sha256: 6b73f6157d72e543df4163fd3e7b55091ada27a76b8267437688e8c43583178e

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

require File.expand_path("../../test/dummy/config/environment.rb",  __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]

require "rails/test_help"
# require 'flexmock/test_unit'  TODO, c'est quoi ca ?

$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__))

#$connection = (ENV['DB'] || 'native_mysql')
$connection = (ENV['DB'] || 'native_postgresql')


Rails.backtrace_cleaner.remove_silencers!

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

# Load fixtures from the engine
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
  ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end



class ActiveSupport::TestCase
  def create_people_view
    ActiveRecord::Base.connection.create_view(:v_people,
 #       'select id, first_name, last_name, ssn, address_id from people', :force => true) do |v|
 # no force option... Error in postgres
         'select id, first_name, last_name, ssn, address_id from people' ) do |v|
      v.column :id
      v.column :f_name
      v.column :l_name
      v.column :social_security
      v.column :address_id
    end
    
    VPerson.primary_key = 'id'
    # sinon, par défaut, il n'y a pas d'ID sous rails, même si il y a l'ID dans la vue de Postgres 
  end
    
  
  
# create view v_people as SELECT people.id,\ people.first_name AS f_name,\n    people.last_name AS l_name,\n    people.ssn AS social_security,\n    people.address_id\n   FROM people;", {:force=>true})

# "CREATE VIEW \"v_people\" (\"id\", \"f_name\", \"l_name\", \"social_security\", \"address_id\") AS select id, first_name, last_name, ssn, address_id from people"
# CREATE VIEW "v_people" ("id", "f_name", "l_name", "social_security", "address_id") AS select id, first_name, last_name, ssn, address_id from people;

  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_sql_views4-0.0.3 test/test_helper.rb