test/test_helper.rb in opro-0.0.1 vs test/test_helper.rb in opro-0.0.2

- old
+ new

@@ -5,10 +5,13 @@ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../') require File.expand_path("../dummy/config/environment.rb", __FILE__) require "rails/test_help" require 'mocha' +require 'timecop' +require 'database_cleaner' +DatabaseCleaner.strategy = :truncation ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.default_url_options[:host] = "test.com" @@ -43,22 +46,22 @@ # gives us the login_as(@user) method when request object is not present include Warden::Test::Helpers Warden.test_mode! def rand_name - 'foo' + Time.now.to_f.to_s + 'foo' + Time.now.to_f.to_s + rand(10000).to_s end def create_user(options = {}) User.create(:email => rand_name + '@bar.com', :password => 'password', :password_confirm => 'password') end def create_client_app(options= {}) user = options[:user] || create_user name = options[:name] || rand_name - Oauth::ClientApplication.create_with_user_and_name(user, name) + Oauth::ClientApp.create_with_user_and_name(user, name) end def user_with_client_app user = create_user create_client_app(:user => user) @@ -66,11 +69,12 @@ end def create_auth_grant_for_user(user = nil, app = nil) app ||= create_client_app user ||= create_user - Oauth::AccessGrant.create(:user => user, :application => app) + Oauth::AuthGrant.create(:user => user, :application => app) end + # Will run the given code as the user passed in def as_user(user=nil, &block) current_user = user || create_user if self.respond_to? :request