Files
redmine_contracts/test/integration/contracts_delete_test.rb
Eric Davis a2b810a4d8 [#4410] Replace Payment Terms with an Enumeration
Instead of using a hard coded value for Payment Terms, they will use
Redmine's Enumeration table.  This provides an admin gui to managing
the value as well as ordering them.
2010-08-12 09:26:09 -07:00

50 lines
1.5 KiB
Ruby

require 'test_helper'
class ContractsDeleteTest < ActionController::IntegrationTest
include Redmine::I18n
def setup
@project = Project.generate!(:identifier => 'main')
@contract = Contract.generate!(:project => @project, :name => 'A Contract')
end
should "allow admins to delete the contract" do
@user = User.generate!(:login => 'admin', :password => 'existing', :password_confirmation => 'existing', :admin => true)
login_as('admin', 'existing')
visit_contracts_for_project(@project)
click_link @contract.id
assert_response :success
click_link 'Update'
assert_response :success
assert_template 'contracts/edit'
assert_select "a[href=?]", contract_path(@project, @contract), :text => /Delete/
click_link 'Delete'
assert_response :success
assert_template 'contracts/index'
assert_nil Contract.find_by_id(@contract.id), "Contract not deleted"
end
should "not allow non-admins to delete the contract" do
visit_contracts_for_project(@project)
click_link @contract.id
assert_response :success
click_link 'Update'
assert_response :success
assert_template 'contracts/edit'
assert_select "a", :text => /Delete/, :count => 0
delete contract_path(@project, @contract)
assert_response :redirect
follow_redirect!
assert_response :success
assert_template 'account/login' # Prompt for login
assert Contract.find_by_id(@contract.id), "Contract deleted"
end
end