replace shoulda context "without workflow privilege" at IssuesControllerTest

git-svn-id: http://svn.redmine.org/redmine/trunk@12785 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2014-02-04 07:50:39 +00:00
parent 05b2bd173e
commit 06c53f878f

View File

@ -2262,14 +2262,14 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal issue, attachment.container assert_equal issue, attachment.container
end end
context "without workflow privilege" do def setup_without_workflow_privilege
setup do
WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id]) WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
Role.anonymous.add_permission! :add_issues, :add_issue_notes Role.anonymous.add_permission! :add_issues, :add_issue_notes
end end
private :setup_without_workflow_privilege
context "#new" do test "without workflow privilege #new should propose default status only" do
should "propose default status only" do setup_without_workflow_privilege
get :new, :project_id => 1 get :new, :project_id => 1
assert_response :success assert_response :success
assert_template 'new' assert_template 'new'
@ -2279,7 +2279,8 @@ class IssuesControllerTest < ActionController::TestCase
end end
end end
should "accept default status" do test "without workflow privilege #new should accept default status" do
setup_without_workflow_privilege
assert_difference 'Issue.count' do assert_difference 'Issue.count' do
post :create, :project_id => 1, post :create, :project_id => 1,
:issue => {:tracker_id => 1, :issue => {:tracker_id => 1,
@ -2290,7 +2291,8 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal IssueStatus.default, issue.status assert_equal IssueStatus.default, issue.status
end end
should "ignore unauthorized status" do test "without workflow privilege #new should ignore unauthorized status" do
setup_without_workflow_privilege
assert_difference 'Issue.count' do assert_difference 'Issue.count' do
post :create, :project_id => 1, post :create, :project_id => 1,
:issue => {:tracker_id => 1, :issue => {:tracker_id => 1,
@ -2300,26 +2302,26 @@ class IssuesControllerTest < ActionController::TestCase
issue = Issue.order('id').last issue = Issue.order('id').last
assert_equal IssueStatus.default, issue.status assert_equal IssueStatus.default, issue.status
end end
end
context "#update" do test "without workflow privilege #update should ignore status change" do
should "ignore status change" do setup_without_workflow_privilege
assert_difference 'Journal.count' do assert_difference 'Journal.count' do
put :update, :id => 1, :issue => {:status_id => 3, :notes => 'just trying'} put :update, :id => 1, :issue => {:status_id => 3, :notes => 'just trying'}
end end
assert_equal 1, Issue.find(1).status_id assert_equal 1, Issue.find(1).status_id
end end
should "ignore attributes changes" do test "without workflow privilege #update ignore attributes changes" do
setup_without_workflow_privilege
assert_difference 'Journal.count' do assert_difference 'Journal.count' do
put :update, :id => 1, :issue => {:subject => 'changed', :assigned_to_id => 2, :notes => 'just trying'} put :update, :id => 1,
:issue => {:subject => 'changed', :assigned_to_id => 2,
:notes => 'just trying'}
end end
issue = Issue.find(1) issue = Issue.find(1)
assert_equal "Can't print recipes", issue.subject assert_equal "Can't print recipes", issue.subject
assert_nil issue.assigned_to assert_nil issue.assigned_to
end end
end
end
context "with workflow privilege" do context "with workflow privilege" do
setup do setup do