Added a few more tests
This commit is contained in:
parent
25737ce46e
commit
cf639202b8
5 changed files with 45 additions and 11 deletions
|
@ -139,16 +139,21 @@ class IssuesController < ApplicationController
|
|||
|
||||
def comment
|
||||
@issue = Issue.find(params[:id])
|
||||
@issue_comment = @issue.comments.build(issue_comment_params)
|
||||
@issue_comment.commenter_user_id = @user.id
|
||||
if params[:reassign]
|
||||
reassign_issue
|
||||
@issue_comment.reassign = true
|
||||
if issue_comment_params.blank?
|
||||
notice = t('issues.comment.provide_details')
|
||||
else
|
||||
@issue_comment = @issue.comments.build(issue_comment_params)
|
||||
@issue_comment.commenter_user_id = @user.id
|
||||
if params[:reassign]
|
||||
reassign_issue
|
||||
@issue_comment.reassign = true
|
||||
end
|
||||
@issue_comment.save!
|
||||
@issue.updated_by = @user.id
|
||||
@issue.save!
|
||||
notice = t('issues.comment.comment_created')
|
||||
end
|
||||
@issue_comment.save!
|
||||
@issue.updated_by = @user.id
|
||||
@issue.save!
|
||||
redirect_to @issue
|
||||
redirect_to @issue, notice: notice
|
||||
end
|
||||
|
||||
# Status Transistions
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<br/>
|
||||
<div class="comment">
|
||||
<%= form_for :issue_comment, :url => { :action => 'comment', :id => @issue.id, :user_id => @user.id } do |f| %>
|
||||
<%= richtext_area :issue_comment, :body, :cols => 10, :rows => 8 %>
|
||||
<%= richtext_area :issue_comment, :body, :cols => 10, :rows => 8, :required => true %>
|
||||
<%= label_tag t('issues.show.comments.reassign_param') %> <%= check_box_tag :reassign, true %>
|
||||
<br/>
|
||||
<br/>
|
||||
|
|
|
@ -956,7 +956,10 @@ en-GB:
|
|||
show:
|
||||
comments:
|
||||
reassign: The Issue was reassigned
|
||||
reassign_param: Reassign Issue?
|
||||
reassign_param: Reassign Issue?
|
||||
comment:
|
||||
provide_details: Please provide the required details
|
||||
comment_created: Your comment was successfully created
|
||||
resolved: Issue status has been set to 'Resolved'
|
||||
ignored: Issue status has been set to 'Ignored'
|
||||
reopened: Issue status has been set to 'Open'
|
||||
|
|
|
@ -927,6 +927,9 @@ en:
|
|||
comments:
|
||||
reassign: The Issue was reassigned
|
||||
reassign_param: Reassign Issue?
|
||||
comment:
|
||||
provide_details: Please provide the required details
|
||||
comment_created: Your comment was successfully created
|
||||
resolved: Issue status has been set to 'Resolved'
|
||||
ignored: Issue status has been set to 'Ignored'
|
||||
reopened: Issue status has been set to 'Open'
|
||||
|
|
|
@ -199,4 +199,27 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def test_comment_by_normal_user
|
||||
# Create Issue
|
||||
test_new_issue_after_login
|
||||
assert_equal Issue.count,1
|
||||
|
||||
get :comment, id: 1
|
||||
assert_response :redirect
|
||||
assert_redirected_to root_path
|
||||
end
|
||||
|
||||
def test_comment
|
||||
# Create Issue
|
||||
test_new_issue_after_login
|
||||
assert_equal Issue.count,1
|
||||
@issue = Issue.all.first
|
||||
|
||||
# Login as administrator
|
||||
session[:user] = users(:administrator_user).id
|
||||
|
||||
get :comment, id: @issue.id, :issue_comment => { body: "test comment" }
|
||||
assert_response :redirect
|
||||
assert_redirected_to @issue
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue