diff --git a/plugins/stoa/test/functional/account_controller_test.rb b/plugins/stoa/test/functional/account_controller_test.rb index 6c603e9..8807dcd 100644 --- a/plugins/stoa/test/functional/account_controller_test.rb +++ b/plugins/stoa/test/functional/account_controller_test.rb @@ -8,30 +8,27 @@ class AccountControllerTest < ActionController::TestCase SALT=YAML::load(File.open(StoaPlugin.root_path + 'config.yml'))['salt'] + @db = Tempfile.new('stoa-test') + configs = ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path} + ActiveRecord::Base.establish_connection(:stoa) + ActiveRecord::Schema.verbose = false + ActiveRecord::Schema.create_table "pessoa" do |t| + t.integer "codpes" + t.text "numcpf" + t.date "dtanas" + end + ActiveRecord::Base.establish_connection(:test) + def setup @controller = AccountController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @db = Tempfile.new('stoa-test') - configs = ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path} - ActiveRecord::Base.establish_connection(:stoa) - ActiveRecord::Schema.verbose = false - ActiveRecord::Schema.create_table "pessoa" do |t| - t.integer "codpes" - t.text "numcpf" - t.date "dtanas" - end - ActiveRecord::Base.establish_connection(:test) - StoaPlugin::UspUser.create!(:codpes => 12345678, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30') + StoaPlugin::UspUser.create!({:codpes => 12345678, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30'}, :without_protection => true) Environment.default.enable_plugin(StoaPlugin.name) @user = create_user('joao-stoa', {:password => 'pass', :password_confirmation => 'pass'},:usp_id=>'87654321') @user.activate end - def teardown - @db.unlink - end - should 'fail if confirmation value doesn\'t match' do #StoaPlugin::UspUser.stubs(:matches?).returns(false) post :signup, :profile_data => {:usp_id => '12345678'}, :confirmation_field => 'cpf', :cpf => '00000000' diff --git a/plugins/stoa/test/unit/usp_user_test.rb b/plugins/stoa/test/unit/usp_user_test.rb index 288648b..59626bc 100644 --- a/plugins/stoa/test/unit/usp_user_test.rb +++ b/plugins/stoa/test/unit/usp_user_test.rb @@ -4,22 +4,19 @@ class StoaPlugin::UspUserTest < ActiveSupport::TestCase SALT=YAML::load(File.open(StoaPlugin.root_path + 'config.yml'))['salt'] - def setup - @db = Tempfile.new('stoa-test') - configs = ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path} - ActiveRecord::Base.establish_connection(:stoa) - ActiveRecord::Schema.verbose = false - ActiveRecord::Schema.create_table "pessoa" do |t| - t.integer "codpes" - t.text "numcpf" - t.date "dtanas" - end - ActiveRecord::Base.establish_connection(:test) - StoaPlugin::UspUser.create!(:codpes => 123456, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30') + @db = Tempfile.new('stoa-test') + configs = ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path} + ActiveRecord::Base.establish_connection(:stoa) + ActiveRecord::Schema.verbose = false + ActiveRecord::Schema.create_table "pessoa" do |t| + t.integer "codpes" + t.text "numcpf" + t.date "dtanas" end + ActiveRecord::Base.establish_connection(:test) - def teardown - @db.unlink + def setup + StoaPlugin::UspUser.create({:codpes => 123456, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30'}, :without_protection => true) end should 'check existence of usp_id' do @@ -48,4 +45,3 @@ class StoaPlugin::UspUserTest < ActiveSupport::TestCase assert !StoaPlugin::UspUser.matches?(123456, nil, '00012345678') end end - -- libgit2 0.21.2