Sha256: 06e342fb429ac4253aecb5073bfc51f8ccb16b0c63898635f19e78b3a995d868

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

def clean_all_shards()
  ActiveRecord::Base.using(:master).connection.instance_variable_get(:@shards).keys.each do |shard_symbol|
    ['schema_migrations', 'users', 'clients', 'cats', 'items', 'keyboards', 'computers', 'permissions_roles', 'roles', 'permissions', 'assignments', 'projects', 'programmers'].each do |tables|
      ActiveRecord::Base.using(shard_symbol).connection.execute("DELETE FROM #{tables};") 
    end
  end
end

def clean_connection_proxy()
  Thread.current[:connection_proxy] = nil  
end

def migrating_to_version(version, &block)
  begin
    ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT, version)
    yield
  ensure
    ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT, version)
  end
end

def using_enviroment(enviroment, &block)
  begin
    set_octopus_env(enviroment.to_s)
    clean_connection_proxy()
    yield
  ensure
    set_octopus_env('octopus')
    clean_connection_proxy()
  end
end

def set_octopus_env(env)
  Octopus.instance_variable_set(:@config, nil)
  Octopus.stub!(:env).and_return(env)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ar-octopus-0.3.0 spec/octopus_helper.rb
ar-octopus-0.2.2 spec/octopus_helper.rb
ar-octopus-0.2.1 spec/octopus_helper.rb
ar-octopus-0.2.0 spec/octopus_helper.rb
ar-octopus-0.1.2 spec/octopus_helper.rb
ar-octopus-0.1.1 spec/octopus_helper.rb
ar-octopus-0.1.0 spec/octopus_helper.rb
ar-octopus-0.0.30 spec/octopus_helper.rb
ar-octopus-0.0.29 spec/octopus_helper.rb
ar-octopus-0.0.28 spec/octopus_helper.rb
ar-octopus-0.0.27 spec/octopus_helper.rb
ar-octopus-0.0.26 spec/octopus_helper.rb
ar-octopus-0.0.25 spec/octopus_helper.rb