test/test_helper.rb in opro-0.4.3 vs test/test_helper.rb in opro-0.5.0

- old
+ new

@@ -11,11 +11,11 @@ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../') require File.expand_path("../dummy/config/environment.rb", __FILE__) require "rails/test_help" -require 'mocha' +require 'mocha/setup' require 'timecop' require 'database_cleaner' DatabaseCleaner.strategy = :truncation ActionMailer::Base.delivery_method = :test @@ -58,11 +58,16 @@ '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') + user = User.new + user.email = rand_name + '@bar.com' + user.password = 'password' + user.password_confirmation = 'password' + user.save + user end def create_client_app(options= {}) user = options[:user] || create_user name = options[:name] || rand_name @@ -76,10 +81,14 @@ end def create_auth_grant_for_user(user = nil, app = nil) app ||= create_client_app user ||= create_user - Opro::Oauth::AuthGrant.create(:user => user, :application => app) + auth_grant = Opro::Oauth::AuthGrant.new + auth_grant.user = user + auth_grant.application = app + auth_grant.save + auth_grant end alias :create_auth_grant :create_auth_grant_for_user