Initial Redmine tooling and local plugin forks

This commit is contained in:
Jason Thistlethwaite
2026-04-24 22:01:18 +00:00
commit 9f682af0eb
683 changed files with 56878 additions and 0 deletions
@@ -0,0 +1,85 @@
require File.expand_path('../../test_helper', __FILE__)
class CannedResponsesControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:canned_responses,
:helpdesk_tickets])
def setup
RedmineHelpdesk::TestCase.prepare
@request.session[:user_id] = 1
# @response = ActionController::TestResponse.new
end
def test_should_get_index
get :index, :project_id => 1
assert_response 200
end
def test_should_get_new
get :new, :project_id => 1
assert_response 200
end
def test_should_get_edit
get :edit, :id => 1
assert_response 200
end
def test_should_post_create
post :create, :canned_response => {:name => "New canned response", :content => "Hi there!", :is_public => false}, :project_id => 1
assert_redirected_to settings_project_path(Project.find('ecookbook'), :tab => 'helpdesk_canned_responses')
assert_equal "New canned response", CannedResponse.last.name
end
def test_should_put_update
put :update, :id => 1, :canned_response => {:name => "New name"}
assert_redirected_to settings_project_path(Project.find('ecookbook'), :tab => 'helpdesk_canned_responses')
assert_equal "New name", CannedResponse.find(1).name
end
def test_should_delete_destroy
delete :destroy, :id => 1
assert_redirected_to settings_project_path(Project.find('ecookbook'), :tab => 'helpdesk_canned_responses')
assert_nil CannedResponse.find_by_id(1)
end
def test_should_get_add
xhr :get, :add, :id => 1, :project_id => 1, :issue_id => 1
assert_response 200
end
end
@@ -0,0 +1,87 @@
require File.expand_path('../../test_helper', __FILE__)
# Re-raise errors caught by the controller.
# class HelpdeskMailerController; def rescue_action(e) raise e end; end
class ContactsControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(
Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/',
[
:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries
]
)
RedmineHelpdesk::TestCase.create_fixtures(
Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/',
[ :journal_messages, :helpdesk_tickets]
)
include RedmineHelpdesk::TestHelper
def setup
RedmineHelpdesk::TestCase.prepare
ActionMailer::Base.deliveries.clear
@controller = ContactsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_contacts_with_closed_tickets
@request.session[:user_id] = 1
get 'index', "f"=>["open_tickets", ""], "op"=>{"open_tickets"=>"="},
"v"=>{"open_tickets"=>["0"]}
assert_response :success
assert !assigns(:contacts).include?(Contact.find(1))
end
def test_contacts_with_open_tickets
@request.session[:user_id] = 1
get 'index', "f"=>["open_tickets", ""], "op" => { "open_tickets" => "=" },
"v" => { "open_tickets"=>["1"] }
assert_response :success
assert assigns(:contacts).include?(Contact.find(1))
end
def test_contacts_with_number_of_tickets
@request.session[:user_id] = 1
get 'index', "f"=>["number_of_tickets", ""], "op"=>{ "number_of_tickets" => "=" },
"v"=>{ "number_of_tickets"=>["1"] }
assert_response :success
assigns(:contacts).each do |contact|
assert contact.helpdesk_tickets.count == 1
end
end
end
@@ -0,0 +1,60 @@
require File.expand_path('../../test_helper', __FILE__)
# require 'contacts_duplicates_controller'
class ContactsDuplicatesControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
def setup
RedmineHelpdesk::TestCase.prepare
@controller = ContactsDuplicatesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_merge_helpdesk_ticket_contacts
@request.session[:user_id] = 1
total_tickets_count = Contact.find(2).tickets.count + Contact.find(1).tickets.count
get :merge, :project_id => 1, :contact_id => 1, :duplicate_id => 2
assert_redirected_to :controller => "contacts", :action => 'show', :id => 2, :project_id => 'ecookbook'
contact = Contact.find(2)
assert_equal total_tickets_count, contact.tickets.count
end
end
@@ -0,0 +1,144 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)
# require 'helpdesk_controller'
class HelpdeskControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
FIXTURES_PATH = Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/helpdesk_mailer'
def setup
RedmineHelpdesk::TestCase.prepare
@controller = HelpdeskController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def credentials(user, password=nil)
ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)
end
def test_show_original
@request.session[:user_id] = 1
Setting.default_language = 'en'
a = Attachment.create!(:container => HelpdeskTicket.find(1),
:file => uploaded_file("new_issue_new_contact_ru_2.eml", "message/rfc822"),
:author => User.find(1))
get :show_original, :id => a, :project_id => 1
assert_response :success
assert_template 'attachments/file'
assert_not_nil assigns(:content)
assert_match 'Программа автоматически заменила категории', @response.body
end
def test_should_delete_spam
@request.session[:user_id] = 1
Setting.default_language = 'en'
issue = Issue.new
issue.copy_from(1).save
contact = Contact.create(:first_name => "New contact", :project => Project.find('ecookbook'), :email => "mail@test.new")
user = User.find(1)
issue.helpdesk_ticket = HelpdeskTicket.new(:customer => contact,
:issue => issue,
:from_address => contact.primary_email,
:ticket_date => Time.now)
issue.save!
assert_not_nil customer = issue.customer
delete :delete_spam, :project_id => 1, :issue_id => issue.id
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
assert_nil Contact.find_by_id(contact.id)
assert_nil Issue.find_by_id(issue.id)
assert_match customer.primary_email, HelpdeskSettings["helpdesk_blacklist", '1']
end
def test_should_save_settings
@request.session[:user_id] = 1
Setting.default_language = 'en'
@project = Project.find('ecookbook')
put :save_settings , :project_id => @project.id, "helpdesk_answer_from" => 'test@test.ru', "helpdesk_lifetime" => 60, :helpdesk_protocol => 'pop3', :helpdesk_host => 'pop3.test.ru'
assert_response :redirect
assert_equal('test@test.ru', ContactsSetting["helpdesk_answer_from", @project.id])
assert_equal('60', ContactsSetting["helpdesk_lifetime", @project.id])
assert_equal('pop3', ContactsSetting[:helpdesk_protocol, @project.id])
assert_equal('pop3.test.ru', ContactsSetting[:helpdesk_host, @project.id])
end
def test_should_notify_sender_on_ticket_created_via_api
user = User.find(1)
user.pref[:no_self_notified] = false
user.pref.save
@request.session[:user_id] = 1
@project = Project.find('ecookbook')
Setting.default_language = 'en'
Setting.rest_api_enabled = 1
ContactsSetting["helpdesk_answer_from", @project.id] = 'test@email.from'
ContactsSetting["helpdesk_send_notification", @project.id] = 1
token = Token.create!(:user => User.find(1), :action => 'api', :value => 'topsecret')
ActionMailer::Base.deliveries = []
post :create_ticket,
:format => :xml,
:project_id => @project.id,
:key => token.value,
:ticket => {
:issue => {
:subject => 'test1',
:tracker_id => Tracker.first.id
},
:contact => {
:email => 'test@example.com',
:first_name => 'John'
}
}
assert_response 201
assert_equal(2, ActionMailer::Base.deliveries.count)
assert_equal(['test@example.com'], ActionMailer::Base.deliveries.last.to)
end
private
def uploaded_file(filename, mime)
fixture_file_upload("../../plugins/redmine_contacts_helpdesk/test/fixtures/helpdesk_mailer/#{filename}", mime, true)
end
end
@@ -0,0 +1,121 @@
require File.expand_path('../../test_helper', __FILE__)
# Re-raise errors caught by the controller.
# class HelpdeskMailerController; def rescue_action(e) raise e end; end
class HelpdeskMailerControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages])
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/helpdesk_mailer'
def setup
RedmineHelpdesk::TestCase.prepare
@controller = HelpdeskMailerController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_should_create_issue
# Enable API and set a key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
post :index, :key => 'secret', :issue => {:project_id => 'ecookbook', :status => 'Closed', :tracker => 'Bug', :assigned_to => 'jsmith'}, :email => IO.read(File.join(FIXTURES_PATH, 'new_issue_new_contact.eml'))
assert_response 201
assert_not_nil Contact.find_by_first_name('New')
end
def test_should_create_issue_from_mailhandler
# Enable API and set a key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
post :index, :key => 'secret', :issue => {:project => 'ecookbook', :status => 'Closed', :tracker => 'Bug', :priority => 'low'}, :email => IO.read(File.join(FIXTURES_PATH, 'new_issue_new_contact.eml'))
assert_response 201
assert_not_nil Contact.find_by_first_name('New')
end
def test_should_use_project_helpdesk_settings_for_issue
# Enable API and set a key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
# Project settings
ContactsSetting["helpdesk_answer_from", Project.find('ecookbook').id] = 'test@email.from'
ContactsSetting["helpdesk_send_notification", Project.find('ecookbook').id] = 1
ContactsSetting["helpdesk_assigned_to", Project.find('ecookbook').id] = 2
ContactsSetting[:helpdesk_issue_due_date,Project.find('ecookbook').id] = Date.today + 5
ActionMailer::Base.deliveries.clear
@request.session[:user_id] = 1
post :index, :key => 'secret', :issue => { :project => 'ecookbook' }, :email => IO.read(File.join(FIXTURES_PATH, 'new_issue_new_contact.eml'))
assert_response 201
issue = Issue.last
assert_equal 'Normal', issue.priority.name
assert_equal Date.today + 5, issue.due_date
assert_equal User.find(2).login, issue.assigned_to.login
contact = issue.customer
assert_equal "New", contact.first_name
end
def test_should_get_mail
# Enable API and set a key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
post :get_mail, :key => 'secret'
assert_response :ok
end
def test_should_change_state_for_ticket_on_reply
project = Project.find_by_identifier('ecookbook')
issue = Issue.find(5)
# Enable API and set a key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
ContactsSetting["helpdesk_reopen_status", project.id] = IssueStatus.where(:name => 'Feedback').first.id
assert_not_equal 'Feedback', issue.status.name
post :index, :key => 'secret', :issue => { :project => 'ecookbook' }, :email => IO.read(File.join(FIXTURES_PATH, 'reply_from_contact.eml'))
issue.reload
assert_equal 'Feedback', issue.status.name
end
end
@@ -0,0 +1,129 @@
require File.expand_path('../../test_helper', __FILE__)
class HelpdeskReportsControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
def setup
RedmineHelpdesk::TestCase.prepare
@controller = HelpdeskReportsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_show_first_response_time_report
HelpdeskDataCollectorFirstResponse.any_instance.stubs(:issues).returns(Issue.where(:id => 1))
@request.session[:user_id] = 1
get :show, :project_id => 'ecookbook', :report => 'first_response_time',
:set_filter => '1',
:f => ['message_date', ''],
:op => { 'message_date' => 't' }
assert_response :success
assert_select '#content h2', /First response time/
assert_select '.chart_table .header .column_data', 8
assert_select '.column_data .percents', 1
assert_select 'tr.metrics td p', /Average first response time/
assert_select 'tr.metrics td p', /Average closing ticket time/
assert_select 'tr.metrics td p', /Average count of responses to close/
assert_select 'tr.metrics td p', /Total replies/
ensure
HelpdeskDataCollectorFirstResponse.any_instance.unstub(:issues)
end
def test_show_first_response_time_report_without_params
HelpdeskDataCollectorFirstResponse.any_instance.stubs(:issues).returns(Issue.where(:id => 1))
@request.session[:user_id] = 1
get :show, :project_id => 'ecookbook', :report => 'first_response_time',
:set_filter => '1',
:f => ['']
assert_response :success
assert_select '#content h2', /First response time/
assert_select '.chart_table .header .column_data', 8
assert_select '.column_data .percents', 1
assert_select 'tr.metrics td p', /Average first response time/
assert_select 'tr.metrics td p', /Average closing ticket time/
assert_select 'tr.metrics td p', /Average count of responses to close/
assert_select 'tr.metrics td p', /Total replies/
ensure
HelpdeskDataCollectorFirstResponse.any_instance.unstub(:issues)
end
def test_show_productivity_report_with_no_data
HelpdeskDataCollectorFirstResponse.any_instance.stubs(:issues).returns(Issue.where(:id => 0))
@request.session[:user_id] = 1
get :show, :project_id => 'ecookbook', :report => 'first_response_time',
:set_filter => '1',
:f => ['message_date', ''],
:op => { 'message_date' => 'lm' }
assert_response :success
assert_select '#content h2', /First response time/
assert_select 'p.nodata', /No data to display/
ensure
HelpdeskDataCollectorFirstResponse.any_instance.unstub(:issues)
end
def test_show_busiest_time_of_day_report
@request.session[:user_id] = 1
get :show, :project_id => 'ecookbook', :report => 'busiest_time_of_day',
:set_filter => '1',
:f => ['message_date', ''],
:op => { 'message_date' => 'y' }
assert_response :success
assert_select '#content h2', /Busiest time of day/
assert_select '.chart_table .header .column_data', 12
assert_select '.column_data .percents', 2
assert_select 'tr.metrics td p', /New tickets/
assert_select 'tr.metrics td p', /New contacts/
assert_select 'tr.metrics td p', /Total incoming/
end
def test_show_busiest_time_of_day_report_with_no_data
HelpdeskDataCollectorBusiestTime.any_instance.stubs(:issues_count).returns(0)
@request.session[:user_id] = 1
get :show, :project_id => 'ecookbook', :report => 'busiest_time_of_day',
:set_filter => '1',
:f => ['message_date', ''],
:op => { 'message_date' => 't' }
assert_response :success
assert_select '#content h2', /Busiest time of day/
assert_select 'p.nodata', /No data to display/
ensure
HelpdeskDataCollectorBusiestTime.any_instance.unstub(:issues_count)
end
end
@@ -0,0 +1,85 @@
require File.expand_path('../../test_helper', __FILE__)
class HelpdeskTicketsControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
def setup
RedmineHelpdesk::TestCase.prepare
end
def test_should_get_edit
@request.session[:user_id] = 1
xhr :get, :edit, :issue_id => 1, :id => 1
assert_response 200
end
def test_should_create_ticket
@request.session[:user_id] = 1
put :update,
:helpdesk_ticket => {:contact_id => 1,
:source => "0",
:ticket_date => "2013-01-01"},
:time => {:hour => 21 , :minute => 12},
:issue_id => 1,
:id => 1
assert_redirected_to :controller => 'issues', :action => 'show', :id => '1'
assert_not_nil HelpdeskTicket.find_by_from_address(Contact.find(1).primary_email)
end
def test_should_destroy
@request.session[:user_id] = 1
delete :destroy, :id => 3
assert_response :redirect
assert_nil HelpdeskTicket.find_by_id(3)
end
def test_should_update_cutomer_profile
@request.session[:user_id] = 1
put :update,
:helpdesk_ticket => {:contact_id => 1,
:source => "2",
:ticket_date => "2013-01-01"},
:issue_id => 12,
:id => 1
assert_redirected_to :controller => 'issues', :action => 'show', :id => '12'
assert_equal Contact.find(1).primary_email, HelpdeskTicket.last.from_address
assert_equal 12, HelpdeskTicket.last.issue_id
assert_equal 2, HelpdeskTicket.last.source
end
end
@@ -0,0 +1,131 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)
class HelpdeskVotesControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
FIXTURES_PATH = Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/helpdesk_mailer'
def setup
RedmineHelpdesk::TestCase.prepare
User.current = nil
RedmineHelpdesk.settings["helpdesk_vote_accept"] = 1
end
def test_should_open_on_correct_token
get :show, :id => 1, :hash => HelpdeskTicket.find(1).token
assert_response :success
assert_match 'Please rate our work', @response.body
end
def test_should_show_404_with_incorrect_token
get :show, :id => 1, :hash => '111111'
assert_response 404
end
def test_should_hide_vote_comment_if_comments_off
RedmineHelpdesk.settings["helpdesk_vote_comment_accept"] = 0
get :show, :id => 1, :hash => HelpdeskTicket.find(1).token
assert_response :success
assert_match 'Please rate our work', @response.body
assert_not_match /Leave a comment/, @response.body if self.respond_to?(:assert_not_match)
end
def test_should_show_vote_comment_if_comments_off
RedmineHelpdesk.settings["helpdesk_vote_comment_accept"] = 1
get :show, :id => 1, :hash => HelpdeskTicket.find(1).token
assert_response :success
assert_match 'Please rate our work', @response.body
assert_match 'Leave a comment', @response.body
end
def test_should_save_last_comment_from_ticket
post :vote, :id => 1, :hash => HelpdeskTicket.find(1).token, :vote => 2, :vote_comment => 'test test'
assert_response :success
assert_match 'Thank you for voting', @response.body
assert_equal(2, HelpdeskTicket.find(1).vote)
assert_equal('test test', HelpdeskTicket.find(1).vote_comment)
end
def test_fast_vote_should_update_ticket_if_comments_off
RedmineHelpdesk.settings["helpdesk_vote_comment_accept"] = 0
get :fast_vote, :id => 1, :vote => 1, :hash => HelpdeskTicket.find(1).token
assert_response :success
assert_match 'Thank you for voting', @response.body
assert_equal(1, HelpdeskTicket.find(1).vote)
end
def test_fast_vote_should_open_vote_page_if_comments_on
RedmineHelpdesk.settings["helpdesk_vote_comment_accept"] = 1
get :fast_vote, :id => 1, :vote => 1, :hash => HelpdeskTicket.find(1).token
assert_response :success
assert_match 'Please rate our work', @response.body
if Redmine::VERSION.to_s >= "3.0"
assert_match 'id="vote_1" value="1" checked="checked"', @response.body
else
assert_match 'input checked="checked" id="vote_1"', @response.body
end
end
def test_should_save_votes_in_logs
RedmineHelpdesk.settings[:helpdesk_vote_save_log] = 1
post :vote, :id => 1, :hash => HelpdeskTicket.find(1).token, :vote => 1, :vote_comment => 'Test test test'
assert_response :success
assert_match 'Thank you for voting', @response.body
assert_equal(1, HelpdeskTicket.find(1).vote)
assert_equal(HelpdeskTicket.find(1).issue, Journal.last.journalized)
assert_equal(1, Journal.last.details.where(:value => '1').count)
assert_equal(1, Journal.last.details.where(:value => 'Test test test').count)
end
def test_vote_journal_save_user_if_he_present
RedmineHelpdesk.settings[:helpdesk_vote_save_log] = 1
@request.session[:user_id] = 2
post :vote, :id => 1, :hash => HelpdeskTicket.find(1).token, :vote => 0
assert_response :success
assert_equal(User.find(2), Journal.last.user)
end
def test_if_user_not_present_vote_anonymous
RedmineHelpdesk.settings[:helpdesk_vote_save_log] = 1
post :vote, :id => 1, :hash => HelpdeskTicket.find(1).token, :vote => 0
assert_response :success
assert_equal(User.where(:lastname => 'Anonymous').first, Journal.last.user)
end
end
@@ -0,0 +1,512 @@
require File.expand_path('../../test_helper', __FILE__)
# Re-raise errors caught by the controller.
# class HelpdeskMailerController; def rescue_action(e) raise e end; end
class IssuesControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
include RedmineHelpdesk::TestHelper
def setup
RedmineHelpdesk::TestCase.prepare
ActionMailer::Base.deliveries.clear
@controller = IssuesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_show_issue
issue = Issue.find(1)
assert_not_nil issue.helpdesk_ticket
get :show, :id => 1
assert_response :success
end
def test_show_reply_to_for_issue_with_ticket
@request.session[:user_id] = 1
issue = Issue.find(1)
assert_not_nil issue.helpdesk_ticket
get :show, :id => issue.id
assert_response :success
assert_equal response.body.match('#content .contextual:first a:first').size, 1
assert_equal response.body.match('#content .contextual:last a:first').size, 1
end
def test_show_reply_to_for_issue_without_ticket
@request.session[:user_id] = 1
issue = Issue.find(3)
assert_nil issue.helpdesk_ticket
get :show, :id => issue.id
assert_response :success
assert_nil response.body.match('#content .contextual:first a:first')
assert_nil response.body.match('#content .contextual:last a:first')
end
def test_show_issue_with_uniq_cc_in_send_note
@request.session[:user_id] = 1
issue = Issue.find(1)
cc_contact = Contact.find(1)
issue.helpdesk_ticket.update_attributes(:cc_address => "#{cc_contact.primary_email},test@email.com")
issue.contacts << cc_contact
with_helpdesk_settings('send_note_by_default' => '1') do
assert_not_nil issue.helpdesk_ticket
get :show, :id => 1
assert_response :success
assert_select '#helpdesk_cc' do
assert_select '[value=?]', cc_contact.primary_email
assert_select '[value=?]', cc_contact.email_name, 0
assert_select '[value=?]', 'test@email.com'
end
end
ensure
issue.contacts = []
issue.helpdesk_ticket.update_attributes(:cc_address => '')
end
def test_get_index_with_filters
ticket = HelpdeskTicket.find(1)
ticket.save
@request.session[:user_id] = 1
get :index, :set_filter =>"1",
:f => ["ticket_reaction_time", ""],
:op => {"ticket_reaction_time" => ">="},
:v => {"ticket_reaction_time"=>["10"]},
:c => ["customer", "ticket_source", "customer_company", "helpdesk_ticket", "ticket_reaction_time", "ticket_first_response_time", "ticket_resolve_time"],
:project_id => "ecookbook"
assert_response :success
end
def test_get_vote_issues
ticket = HelpdeskTicket.find(1)
ticket.update_attributes(:vote => 1, :vote_comment => 'Good!')
@request.session[:user_id] = 1
get :index, :set_filter =>"1",
:f => ["vote", ""],
:op => { "vote" => "*" },
:c => ["tracker", "vote", "vote_comment"],
:project_id => "ecookbook"
assert_response :success
assert_select "table.list.issues td.vote span", /Just ok/
assert_select "table.list.issues td.vote_comment p", /Good/
end
def test_get_not_vote_issues
ticket = HelpdeskTicket.find(1)
ticket.update_attributes(:vote => 1, :vote_comment => 'Good!')
@request.session[:user_id] = 1
get :index, :set_filter =>"1",
:f => ["vote", ""],
:op => { "vote" => "!*" },
:c => ["tracker", "vote", "vote_comment"],
:project_id => "ecookbook"
assert_response :success
assert_select "table.list.issues td.vote", ""
end
def test_get_only_bad_voted_issues
ticket = HelpdeskTicket.find(1)
ticket.update_attributes(:vote => 1, :vote_comment => 'Good!')
ticket = HelpdeskTicket.find(2)
ticket.update_attributes(:vote => 0, :vote_comment => 'Bad!')
@request.session[:user_id] = 1
get :index, :set_filter =>"1",
:f => ["vote", ""],
:op => { "vote" => "=" },
:v => { "vote" => ["0"] },
:c => ["tracker", "vote", "vote_comment"],
:project_id => "ecookbook"
assert_response :success
assert_select "table.list.issues td.vote span", /Not good/
assert_select "table.list.issues td.vote_comment p", /Bad/
assert_select "table.list.issues td.vote span" do |votes|
votes.each do |vote|
assert_match /^((?!Just ok).)*/, vote.to_s
end
end
end
def test_get_tickets_as_csv
ticket = HelpdeskTicket.find(1)
ticket.update_attributes(:vote => 1, :vote_comment => 'Good!')
ticket = HelpdeskTicket.find(2)
ticket.update_attributes(:vote => 0, :vote_comment => 'Bad!')
@request.session[:user_id] = 1
get :index, :set_filter =>"1",
:f => ["vote", ""],
:op => { "vote" => "=" },
:v => { "vote"=>["1", "0"] },
:c => ["tracker", "vote", "vote_comment", "last_message", "last_message_date", "customer", "ticket_source", "customer_company", "helpdesk_ticket", "ticket_reaction_time", "ticket_first_response_time", "ticket_resolve_time"],
:project_id => "ecookbook"
get :index, :format => 'csv'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal "text/csv; header=present", @response.content_type
assert @response.body.starts_with?("#,")
end
def test_should_send_note
user = User.find(1)
@request.session[:user_id] = 1
notes = "Hello, %%NAME%%\r\n Bye, %%NOTE_AUTHOR.FIRST_NAME%%"
# anonymous user
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:issue => {:notes => notes}
assert_redirected_to :action => 'show', :id => '1'
j = Journal.order('id DESC').first
assert_equal "Hello, Ivan\r\n Bye, #{user.firstname}", j.notes
assert_equal 0, j.details.size
assert_equal User.find(1), j.user
mail = last_ticket_mail
assert_mail_body_match "Hello, Ivan\r\n Bye, #{user.firstname}", mail
assert_equal Issue.find(1).customer.primary_email, mail.to.first
end
def test_should_calculate_metrics
@request.session[:user_id] = 1
issue = Issue.find(1)
issue.journals.destroy_all
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:issue => {:notes => 'Response to customer'}
issue.reload
assert_not_nil issue.helpdesk_ticket.first_response_time
assert (issue.helpdesk_ticket.reaction_time - issue.helpdesk_ticket.first_response_time) < 100
end
def test_should_forward_note
user = User.find(1)
@request.session[:user_id] = 1
notes = "Hello, %%NAME%%\r\n Bye, %%NOTE_AUTHOR.FIRST_NAME%%"
# anonymous user
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:journal_message => {:to_address => ["jsmith@somenet.foo"]},
:issue => {:notes => notes}
assert_redirected_to :action => 'show', :id => '1'
j = Journal.order('id DESC').first
assert_match "Hello, Ivan\r\n Bye, #{user.firstname}", j.notes
assert_equal 0, j.details.size
assert_equal User.find(1), j.user
assert_equal Contact.find(4), j.journal_message.contact
mail = last_ticket_mail
assert_mail_body_match "Hello, Ivan\r\n Bye, #{user.firstname}", mail
assert_equal "jsmith@somenet.foo", mail.to.first
end
def test_should_send_note_with_bcc
issue = Issue.find(1)
contact = Contact.find(1)
user = User.find(1)
issue.helpdesk_ticket = HelpdeskTicket.new(:customer => contact,
:issue => issue,
:from_address => contact.primary_email,
:ticket_date => Time.now)
issue.save!
@request.session[:user_id] = 1
notes = "Hello, %%NAME%%\r\n Bye, %%NOTE_AUTHOR.FIRST_NAME%%"
# anonymous user
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:journal_message => {:bcc_address => ["mail1@mail.com", "mail2@mail.com"]},
:issue => {:notes => notes}
assert_redirected_to :action => 'show', :id => '1'
j = Journal.order('id DESC').first
assert_equal "Hello, Ivan\r\n Bye, #{user.firstname}", j.notes
assert_equal 0, j.details.size
assert_equal User.find(1), j.user
mail = last_ticket_mail
assert_mail_body_match "Hello, Ivan\r\n Bye, #{user.firstname}", mail
assert_equal Issue.find(1).customer.primary_email, mail.to.first
assert_equal ["mail1@mail.com", "mail2@mail.com"].sort, mail.bcc.sort
end
def test_should_not_send_note_with_cc
issue = Issue.find(1)
contact = Contact.find(1)
user = User.find(1)
issue.helpdesk_ticket = HelpdeskTicket.new(:customer => contact,
:issue => issue,
:from_address => contact.primary_email,
:ticket_date => Time.now)
issue.save!
@request.session[:user_id] = 1
notes = "Hello, %%NAME%%\r\n Bye, %%NOTE_AUTHOR.FIRST_NAME%%"
# anonymous user
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:journal_message => {:cc_address => ["mail3@mail.com", "mail4@mail.com"]},
:issue => {:notes => notes}
assert_redirected_to :action => 'show', :id => '1'
j = Journal.order('id DESC').first
assert_equal "Hello, Ivan\r\n Bye, #{user.firstname}", j.notes
assert_equal 0, j.details.size
assert_equal User.find(1), j.user
mail = last_ticket_mail
assert_mail_body_match "Hello, Ivan\r\n Bye, #{user.firstname}", mail
assert_equal Issue.find(1).customer.primary_email, mail.to.first
assert_equal ["mail3@mail.com", "mail4@mail.com"].sort, mail.cc.sort
assert mail.bcc.empty?, "Bcc should be empty"
end
def test_should_send_note_with_attachments
issue = Issue.find(1)
contact = Contact.find(1)
user = User.find(1)
issue.helpdesk_ticket = HelpdeskTicket.new(:customer => contact,
:issue => issue,
:from_address => contact.primary_email,
:ticket_date => Time.now)
issue.save!
@request.session[:user_id] = user.id
notes = "Hello, %%NAME%%\r\n Bye, %%NOTE_AUTHOR.FIRST_NAME%%"
# anonymous user
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:issue => {:notes => notes},
:attachments => {'1' => {'file' => helpdesk_uploaded_file('attachment.zip', 'application/octet-stream')}}
mail = last_ticket_mail
assert_not_nil mail.attachments
assert_equal 3855, mail.attachments.first.decoded.size
end
def test_should_send_private_note_with_attachments
issue = Issue.find(1)
contact = Contact.find(1)
user = User.find(1)
issue.helpdesk_ticket = HelpdeskTicket.new(:customer => contact,
:issue => issue,
:from_address => contact.primary_email,
:ticket_date => Time.now)
issue.save!
@request.session[:user_id] = user.id
notes = "Hello, %%NAME%%\r\n Bye, %%NOTE_AUTHOR.FIRST_NAME%%"
# anonymous user
put :update,
:id => 1,
:helpdesk => { :is_send_mail => 1 },
:issue => { :notes => notes, :private_notes => 1 },
:attachments => { '1' => { 'file' => helpdesk_uploaded_file('attachment.zip', 'application/octet-stream') } }
assert_equal issue.reload.journals.last.private_notes, true
mail = last_ticket_mail
assert_not_nil mail.attachments
assert_equal 3855, mail.attachments.first.decoded.size
end
def test_should_send_note_issue_from_anonymous
issue = Issue.find(1)
issue.author_id = 6
contact = Contact.find(1)
user = User.find(1)
issue.helpdesk_ticket = HelpdeskTicket.new(:customer => contact,
:issue => issue,
:from_address => contact.primary_email,
:ticket_date => Time.now)
issue.save!
@request.session[:user_id] = 1
notes = "Hello, %%NAME%%\r\n Bye, %%NOTE_AUTHOR.FIRST_NAME%%"
# anonymous user
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:issue => { :notes => notes }
assert_redirected_to :action => 'show', :id => '1'
j = Journal.order('id DESC').first
assert_equal "Hello, Ivan\r\n Bye, #{user.firstname}", j.notes
assert_equal 0, j.details.size
assert_equal User.find(1), j.user
mail = last_ticket_mail
assert_mail_body_match "Hello, Ivan\r\n Bye, #{user.firstname}", mail
assert_equal Issue.find(1).customer.primary_email, mail.to.first
end
def test_should_create_ticket
@request.session[:user_id] = 1
project = Project.find('ecookbook')
assert_difference 'HelpdeskTicket.count' do
post :create,
:issue => {:tracker_id => 3, :subject => "test", :status_id => 2, :priority_id => 5,
:helpdesk_ticket_attributes => {:contact_id => 1,
:source => "0",
:ticket_date => "2013-01-01 01:01:01 +0400"}},
:project_id => project
end
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
assert_not_nil Issue.last.helpdesk_ticket
end
def test_should_send_auto_answer
@request.session[:user_id] = 1
project = Project.find('ecookbook')
assert_difference 'HelpdeskTicket.count' do
post :create,
:issue => {:tracker_id => 3, :subject => "test", :status_id => 2,
:priority_id => 5, :description => "test description",
:helpdesk_ticket_attributes => {:contact_id => 1,
:source => "0",
:ticket_date => "2013-01-01 01:01:01 +0400"}},
:helpdesk_send_as => HelpdeskTicket::SEND_AS_NOTIFICATION,
:project_id => 1
end
mail = last_ticket_mail
assert_mail_body_match "We hereby confirm that we have received your message", mail
end
def test_should_send_initial_message
with_helpdesk_settings("helpdesk_first_answer_subject" => 'Message for ticket id: #{%ticket.id%}') do
@request.session[:user_id] = 1
project = Project.find('ecookbook')
assert_difference 'HelpdeskTicket.count' do
post :create,
:issue => {:tracker_id => 3, :subject => "test", :status_id => 2,
:priority_id => 5, :description => "test initial description",
:helpdesk_ticket_attributes => {:contact_id => 1,
:source => "0",
:ticket_date => "2013-01-01 01:01:01 +0400"}},
:helpdesk_send_as => HelpdeskTicket::SEND_AS_MESSAGE,
:project_id => 1
end
mail = last_ticket_mail
assert_mail_body_match "test initial description", mail
assert_equal mail.subject, "Message for ticket id: \##{Issue.maximum(:id)}"
assert_equal HelpdeskTicket.order('id ASC').last.message_id, mail.message_id
assert_equal false, HelpdeskTicket.order('id ASC').last.is_incoming
end
end
def test_should_not_create_ticket_for_invalid_issue
@request.session[:user_id] = 1
project = Project.find('ecookbook')
ActionMailer::Base.deliveries.clear
put :update,
:id => 1,
:helpdesk => {:is_send_mail => 1},
:issue => { :notes => 'Test notes', :subject => '' }
assert_equal ActionMailer::Base.deliveries, []
end
def test_should_not_create_ticket_with_empty_customer
@request.session[:user_id] = 1
project = Project.find('ecookbook')
assert_no_difference 'HelpdeskTicket.count' do
post :create,
:issue => {:tracker_id => 3, :subject => "Test subject", :status_id => 2, :priority_id => 5,
:helpdesk_ticket_attributes => {:source => "0",
:contact_id => '',
:ticket_date => "2013-01-01 01:01:01 +0400"}},
:project_id => project
if ActiveRecord::VERSION::MAJOR >= 4
assert_select 'div#errorExplanation', /customer cannot be blank/i
else
assert_error_tag :content => /helpdesk_ticket.customer can&#x27;t be blank/i
end
end
end
def test_put_update_form
if ActiveRecord::VERSION::MAJOR < 4
@request.session[:user_id] = 1
issue = Issue.find(1)
ContactsSetting["helpdesk_tracker", issue.project.id] = 2
xhr :put, :update_form,
:issue => {:tracker_id => 2,
:helpdesk_ticket_attributes => {:contact_id => 3,
:source => HelpdeskTicket::HELPDESK_PHONE_SOURCE}},
:helpdesk_send_as => HelpdeskTicket::SEND_AS_MESSAGE,
:project_id => issue.project
assert_response :success
assert_equal 'text/javascript', response.content_type
assert_template 'update_form'
issue = assigns(:issue)
assert_kind_of Issue, issue
assert_equal 3, issue.helpdesk_ticket.customer.id
assert_equal HelpdeskTicket::HELPDESK_PHONE_SOURCE, issue.helpdesk_ticket.source
end
end
def test_should_set_from_field_for_ticket
@request.session[:user_id] = 1
project = Project.find('ecookbook')
contact = Contact.find(1)
assert_difference 'HelpdeskTicket.count' do
post :create,
:issue => {:tracker_id => 3, :subject => "test_for_field", :status_id => 2, :priority_id => 5,
:helpdesk_ticket_attributes => {:contact_id => contact.id,
:source => "0",
:ticket_date => "2013-01-01 01:01:01 +0400"}},
:project_id => project
end
assert_not_nil Issue.last.helpdesk_ticket
assert_equal Issue.last.helpdesk_ticket.from_address, contact.primary_email
end
private
def last_ticket_mail
ActionMailer::Base.deliveries.detect{|m| m["X-Redmine-Ticket-ID"]}
end
end
@@ -0,0 +1,8 @@
require File.expand_path('../../test_helper', __FILE__)
class MailFetcherControllerTest < ActionController::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end
@@ -0,0 +1,115 @@
require File.expand_path('../../test_helper', __FILE__)
class PublicTicketsControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
def setup
RedmineHelpdesk::TestCase.prepare
RedmineHelpdesk.settings["helpdesk_public_tickets"] = 1
@request.session[:user_id] = User.anonymous.id
# @response = ActionController::TestResponse.new
end
def test_should_show_issue_with_correct_hash
get :show, :id => 1, :hash => HelpdeskTicket.order('id ASC').first.token
assert_response 200
end
def test_should_show_404_with_incorrect_hash
get :show, :id => 1, :hash => '123'
assert_response 404
end
def test_should_not_show_private_issues_and_notes
private_issue = Issue.find(5)
private_issue.is_private = true
private_issue.save
get :show, :id => 1, :hash => HelpdeskTicket.order('id ASC').first.token
assert_select 'div#sidebar .issue', {:html => /#{private_issue.subject}/, :count => 0}
end
def test_should_show_404_with_public_deny
RedmineHelpdesk.settings["helpdesk_public_tickets"] = 0
get :show, :id => 1, :hash => HelpdeskTicket.order('id ASC').first.token
assert_response 404
end
def test_should_show_creator_email
get :show, :id => 1, :hash => HelpdeskTicket.order('id ASC').first.token
assert_select "p.author", /#{HelpdeskTicket.first.from_address}/
end
def test_should_add_comment
RedmineHelpdesk.settings["helpdesk_public_comments"] = 1
ticket = HelpdeskTicket.find(1)
get :add_comment, :id => 1, :hash => ticket.token, :journal => {:notes => "Test public comment"}
assert_equal "Test public comment", Journal.order('id DESC').first.notes
assert_equal Journal.order('id DESC').first.created_on.to_date.to_s, JournalMessage.order('id DESC').first.message_date.to_date.to_s
get :show, :id => 1, :hash => ticket.token
assert_select ".journal .wiki p", /Test public comment/
end
def test_should_change_status
ticket = HelpdeskTicket.order('id ASC').first
reopen_status = IssueStatus.where('id != ?', ticket.issue.status).last
RedmineHelpdesk.settings["helpdesk_public_comments"] = 1
ContactsSetting["helpdesk_reopen_status", ticket.issue.project_id] = reopen_status.id
get :add_comment, :id => 1, :hash => ticket.token, :journal => { :notes => 'Test public comment' }
assert_equal reopen_status, Journal.order('id DESC').last.issue.status
assert_equal reopen_status, ticket.issue.reload.status
end
def test_should_not_add_comment_if_deny
RedmineHelpdesk.settings["helpdesk_public_comments"] = 0
get :add_comment, :id => 1, :hash => HelpdeskTicket.first.token, :journal => {:notes => "Test comment"}
assert_response 404
end
def test_should_show_followups
@request.session[:user_id] = 1
#first(:order => 'id ASC').issue.journals.create(:journalized_type => 'Issue', :notes => 'Followup1')
#puts HelpdeskTicket.order('id ASC').first.issue.journals
journal = HelpdeskTicket.order('id ASC').first.issue.journals.create(:journalized_type => 'Issue', :notes => 'Followup1')
journal_message = journal.create_journal_message(:contact => Contact.order('id ASC').first, :is_incoming => true, :from_address => Contact.order('id ASC').first.email, :message_date => Time.now)
assert journal_message.valid?
get :show, :id => 1, :hash => HelpdeskTicket.order('id ASC').first.token
assert_select ".journal h4", /#{Contact.order('id ASC').first.email}/
end
end
@@ -0,0 +1,52 @@
require File.expand_path('../../test_helper', __FILE__)
class TimelogControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
:contacts_projects,
:contacts_issues,
:deals_issues,
:deals,
:notes,
:tags,
:taggings,
:queries])
RedmineHelpdesk::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts_helpdesk).directory + '/test/fixtures/', [:journal_messages,
:helpdesk_tickets])
def setup
RedmineHelpdesk::TestCase.prepare
end
def test_get_report_with_customer
@request.session[:user_id] = 1
get :report, :columns => "month", :criteria => ["customer"], :project_id => "ecookbook"
assert_response :success
assert_select "table#time-report td", /Ivan/
end
end