From 97a4f4ad1bf59ddbc6973163dfa3c7c913059390 Mon Sep 17 00:00:00 2001 From: Luciano Prestes Cavalcanti Date: Wed, 19 Nov 2014 17:20:10 -0200 Subject: [PATCH] Test for create software when task is accepted --- test/unit/software_registration_test.rb | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/test/unit/software_registration_test.rb b/test/unit/software_registration_test.rb index f415e8a..b6b111a 100644 --- a/test/unit/software_registration_test.rb +++ b/test/unit/software_registration_test.rb @@ -3,20 +3,31 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' class SoftwareRegistrationTest < ActiveSupport::TestCase def setup - @community = Community.new(:name => "test") - @community.save - @atributes = {} - #@license_info = LicenseInfo::new - @atributes = {:name => @community.name} @environment = Environment.default @environment.enable_plugin(MpogSoftwarePlugin) end + def teardown + Community.destroy_all + SoftwareInfo.destroy_all + Task.destroy_all + end + should 'include software registration task if is admin' do person = create_user('molly').person @environment.add_admin(person) - task = CreateSoftware.create!(@atributes.merge(:requestor => person,:environment => @environment)) - Person.any_instance.stubs(:is_admin?).returns(true) + task = CreateSoftware.create!(:name => "Teste One", :requestor => person,:environment => @environment) assert_equal [task], Task.to(person).pending end + + should 'create software when admin accept software create task' do + person = create_user('Pedro').person + @environment.add_admin(person) + task = CreateSoftware.create!(:name => "Teste Two", :requestor => person,:environment => @environment) + + software_count = SoftwareInfo.count + task.finish + + assert_equal software_count+1, SoftwareInfo.count + end end -- libgit2 0.21.2