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:
parent
05b2bd173e
commit
06c53f878f
|
@ -2262,63 +2262,65 @@ 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
|
||||||
|
private :setup_without_workflow_privilege
|
||||||
|
|
||||||
|
test "without workflow privilege #new should propose default status only" do
|
||||||
|
setup_without_workflow_privilege
|
||||||
|
get :new, :project_id => 1
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'new'
|
||||||
|
assert_select 'select[name=?]', 'issue[status_id]' do
|
||||||
|
assert_select 'option', 1
|
||||||
|
assert_select 'option[value=?]', IssueStatus.default.id.to_s
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "#new" do
|
test "without workflow privilege #new should accept default status" do
|
||||||
should "propose default status only" do
|
setup_without_workflow_privilege
|
||||||
get :new, :project_id => 1
|
assert_difference 'Issue.count' do
|
||||||
assert_response :success
|
post :create, :project_id => 1,
|
||||||
assert_template 'new'
|
:issue => {:tracker_id => 1,
|
||||||
assert_select 'select[name=?]', 'issue[status_id]' do
|
|
||||||
assert_select 'option', 1
|
|
||||||
assert_select 'option[value=?]', IssueStatus.default.id.to_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
should "accept default status" do
|
|
||||||
assert_difference 'Issue.count' do
|
|
||||||
post :create, :project_id => 1,
|
|
||||||
:issue => {:tracker_id => 1,
|
|
||||||
:subject => 'This is an issue',
|
:subject => 'This is an issue',
|
||||||
:status_id => 1}
|
:status_id => 1}
|
||||||
end
|
end
|
||||||
issue = Issue.order('id').last
|
issue = Issue.order('id').last
|
||||||
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
|
||||||
assert_difference 'Issue.count' do
|
setup_without_workflow_privilege
|
||||||
post :create, :project_id => 1,
|
assert_difference 'Issue.count' do
|
||||||
|
post :create, :project_id => 1,
|
||||||
:issue => {:tracker_id => 1,
|
:issue => {:tracker_id => 1,
|
||||||
:subject => 'This is an issue',
|
:subject => 'This is an issue',
|
||||||
:status_id => 3}
|
:status_id => 3}
|
||||||
end
|
|
||||||
issue = Issue.order('id').last
|
|
||||||
assert_equal IssueStatus.default, issue.status
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
issue = Issue.order('id').last
|
||||||
|
assert_equal IssueStatus.default, issue.status
|
||||||
|
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
|
|
||||||
assert_equal 1, Issue.find(1).status_id
|
|
||||||
end
|
|
||||||
|
|
||||||
should "ignore attributes changes" do
|
|
||||||
assert_difference 'Journal.count' do
|
|
||||||
put :update, :id => 1, :issue => {:subject => 'changed', :assigned_to_id => 2, :notes => 'just trying'}
|
|
||||||
end
|
|
||||||
issue = Issue.find(1)
|
|
||||||
assert_equal "Can't print recipes", issue.subject
|
|
||||||
assert_nil issue.assigned_to
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
assert_equal 1, Issue.find(1).status_id
|
||||||
|
end
|
||||||
|
|
||||||
|
test "without workflow privilege #update ignore attributes changes" do
|
||||||
|
setup_without_workflow_privilege
|
||||||
|
assert_difference 'Journal.count' do
|
||||||
|
put :update, :id => 1,
|
||||||
|
:issue => {:subject => 'changed', :assigned_to_id => 2,
|
||||||
|
:notes => 'just trying'}
|
||||||
|
end
|
||||||
|
issue = Issue.find(1)
|
||||||
|
assert_equal "Can't print recipes", issue.subject
|
||||||
|
assert_nil issue.assigned_to
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with workflow privilege" do
|
context "with workflow privilege" do
|
||||||
|
|
Loading…
Reference in New Issue