More test fixed for redmine 4
This commit is contained in:
parent
3421763669
commit
10fdd1fee7
@ -1 +0,0 @@
|
|||||||
functional
|
|
@ -9,25 +9,23 @@ class AccountControllerTest < Additionals::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_get_login_with_welcome_text
|
def test_get_login_with_welcome_text
|
||||||
with_additionals_settings(account_login_bottom: 'Lore impsuum')
|
with_additionals_settings(account_login_bottom: 'Lore impsuum') do
|
||||||
|
get :login
|
||||||
get :login
|
assert_response :success
|
||||||
assert_response :success
|
assert_select 'input[name=username]'
|
||||||
|
assert_select 'input[name=password]'
|
||||||
assert_select 'input[name=username]'
|
assert_select 'div.login-additionals', text: /Lore impsuum/
|
||||||
assert_select 'input[name=password]'
|
end
|
||||||
assert_select 'div.login-additionals', text: /Lore impsuum/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_login_without_welcome_text
|
def test_get_login_without_welcome_text
|
||||||
with_additionals_settings(account_login_bottom: '')
|
with_additionals_settings(account_login_bottom: '') do
|
||||||
|
get :login
|
||||||
get :login
|
assert_response :success
|
||||||
assert_response :success
|
assert_select 'input[name=username]'
|
||||||
|
assert_select 'input[name=password]'
|
||||||
assert_select 'input[name=username]'
|
assert_select 'div.login-additionals', count: 0
|
||||||
assert_select 'input[name=password]'
|
end
|
||||||
assert_select 'div.login-additionals', count: 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# See integration/account_test.rb for the full test
|
# See integration/account_test.rb for the full test
|
||||||
|
@ -86,42 +86,47 @@ class IssuesControllerTest < Additionals::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'show assign-to-me on issue' do
|
test 'show assign-to-me on issue' do
|
||||||
with_additionals_settings(issue_assign_to_me: 1)
|
with_additionals_settings(issue_assign_to_me: 1) do
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 2 }
|
params: { id: 2 }
|
||||||
assert_select 'a.assign-to-me'
|
assert_select 'a.assign-to-me'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'don\'t show assign-to-me on issue without activation' do
|
test 'don\'t show assign-to-me on issue without activation' do
|
||||||
with_additionals_settings(issue_assign_to_me: 0)
|
with_additionals_settings(issue_assign_to_me: 0) do
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 2 }
|
params: { id: 2 }
|
||||||
assert_select 'a.assign-to-me', count: 0
|
assert_select 'a.assign-to-me', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'don\'t show assign-to-me on issue with already assigned_to me' do
|
test 'don\'t show assign-to-me on issue with already assigned_to me' do
|
||||||
with_additionals_settings(issue_assign_to_me: 1)
|
with_additionals_settings(issue_assign_to_me: 1) do
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 4 }
|
params: { id: 4 }
|
||||||
assert_select 'a.assign-to-me', count: 0
|
assert_select 'a.assign-to-me', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'show change status in issue sidebar' do
|
test 'show change status in issue sidebar' do
|
||||||
with_additionals_settings(issue_change_status_in_sidebar: 1)
|
with_additionals_settings(issue_change_status_in_sidebar: 1) do
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 2 }
|
params: { id: 2 }
|
||||||
assert_select 'ul.issue-status-change-sidebar'
|
assert_select 'ul.issue-status-change-sidebar'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'don\'t show change status in issue sidebar without activation' do
|
test 'don\'t show change status in issue sidebar without activation' do
|
||||||
with_additionals_settings(issue_change_status_in_sidebar: 0)
|
with_additionals_settings(issue_change_status_in_sidebar: 0) do
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 2 }
|
params: { id: 2 }
|
||||||
assert_select 'ul.issue-status-change-sidebar', count: 0
|
assert_select 'ul.issue-status-change-sidebar', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -20,22 +20,24 @@ class ProjectsControllerTest < Additionals::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_overview_content
|
def test_show_overview_content
|
||||||
with_additionals_settings(project_overview_content: 'Lore impsuum')
|
with_additionals_settings(project_overview_content: 'Lore impsuum') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 1 }
|
params: { id: 1 }
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.project-content', text: /Lore impsuum/
|
assert_select 'div.project-content', text: /Lore impsuum/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_do_not_show_overview_content_box
|
def test_do_not_show_overview_content_box
|
||||||
with_additionals_settings(project_overview_content: '')
|
with_additionals_settings(project_overview_content: '') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 1 }
|
params: { id: 1 }
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.project-content', count: 0
|
assert_select 'div.project-content', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -23,18 +23,20 @@ class UsersControllerTest < Additionals::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_new_issue_on_profile
|
def test_show_new_issue_on_profile
|
||||||
with_additionals_settings(new_issue_on_profile: 1)
|
with_additionals_settings(new_issue_on_profile: 1) do
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 2 }
|
params: { id: 2 }
|
||||||
assert_select 'a.user-new-issue'
|
assert_select 'a.user-new-issue'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_not_show_new_issue_on_profile_without_activated
|
def test_not_show_new_issue_on_profile_without_activated
|
||||||
with_additionals_settings(new_issue_on_profile: 0)
|
with_additionals_settings(new_issue_on_profile: 0) do
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :show,
|
get :show,
|
||||||
params: { id: 2 }
|
params: { id: 2 }
|
||||||
assert_select 'a.user-new-issue', count: 0
|
assert_select 'a.user-new-issue', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,56 +9,62 @@ class WelcomeControllerTest < Additionals::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_with_overview_right
|
def test_show_with_overview_right
|
||||||
with_additionals_settings(overview_right: 'Lore impsuum')
|
with_additionals_settings(overview_right: 'Lore impsuum') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :index
|
get :index
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.overview-right', text: /Lore impsuum/
|
assert_select 'div.overview-right', text: /Lore impsuum/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_without_overview_right
|
def test_show_without_overview_right
|
||||||
with_additionals_settings(overview_right: '')
|
with_additionals_settings(overview_right: '') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :index
|
get :index
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.overview-right', count: 0
|
assert_select 'div.overview-right', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_with_overview_bottom
|
def test_show_with_overview_bottom
|
||||||
with_additionals_settings(overview_bottom: 'Lore impsuum')
|
with_additionals_settings(overview_bottom: 'Lore impsuum') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :index
|
get :index
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.overview-bottom', text: /Lore impsuum/
|
assert_select 'div.overview-bottom', text: /Lore impsuum/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_without_overview_bottom
|
def test_show_without_overview_bottom
|
||||||
with_additionals_settings(overview_bottom: '')
|
with_additionals_settings(overview_bottom: '') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :index
|
get :index
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.overview-bottom', count: 0
|
assert_select 'div.overview-bottom', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_with_overview_top
|
def test_show_with_overview_top
|
||||||
with_additionals_settings(overview_top: 'Lore impsuum')
|
with_additionals_settings(overview_top: 'Lore impsuum') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :index
|
get :index
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.overview-top', text: /Lore impsuum/
|
assert_select 'div.overview-top', text: /Lore impsuum/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_without_overview_top
|
def test_show_without_overview_top
|
||||||
with_additionals_settings(overview_top: '')
|
with_additionals_settings(overview_top: '') do
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
get :index
|
get :index
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'div.overview-top', count: 0
|
assert_select 'div.overview-top', count: 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -368,42 +368,42 @@ class WikiControllerTest < Additionals::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_show_wiki_with_header
|
def test_show_wiki_with_header
|
||||||
with_additionals_settings(global_wiki_header: 'Lore impsuum')
|
with_additionals_settings(global_wiki_header: 'Lore impsuum') do
|
||||||
|
get :show,
|
||||||
|
params: { project_id: 1, id: 'Another_page' }
|
||||||
|
|
||||||
get :show,
|
assert_response :success
|
||||||
params: { project_id: 1, id: 'Another_page' }
|
assert_select 'div#wiki_extentions_header', text: /Lore impsuum/
|
||||||
|
end
|
||||||
assert_response :success
|
|
||||||
assert_select 'div#wiki_extentions_header', text: /Lore impsuum/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_wiki_without_header
|
def test_show_wiki_without_header
|
||||||
with_additionals_settings(global_wiki_header: '')
|
with_additionals_settings(global_wiki_header: '') do
|
||||||
|
get :show,
|
||||||
|
params: { project_id: 1, id: 'Another_page' }
|
||||||
|
|
||||||
get :show,
|
assert_response :success
|
||||||
params: { project_id: 1, id: 'Another_page' }
|
assert_select 'div#wiki_extentions_header', count: 0
|
||||||
|
end
|
||||||
assert_response :success
|
|
||||||
assert_select 'div#wiki_extentions_header', count: 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_wiki_with_footer
|
def test_show_wiki_with_footer
|
||||||
with_additionals_settings(global_wiki_footer: 'Lore impsuum')
|
with_additionals_settings(global_wiki_footer: 'Lore impsuum') do
|
||||||
|
get :show,
|
||||||
|
params: { project_id: 1, id: 'Another_page' }
|
||||||
|
|
||||||
get :show,
|
assert_response :success
|
||||||
params: { project_id: 1, id: 'Another_page' }
|
assert_select 'div#wiki_extentions_footer', text: /Lore impsuum/
|
||||||
|
end
|
||||||
assert_response :success
|
|
||||||
assert_select 'div#wiki_extentions_footer', text: /Lore impsuum/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_wiki_without_footer
|
def test_show_wiki_without_footer
|
||||||
with_additionals_settings(global_wiki_footer: '')
|
with_additionals_settings(global_wiki_footer: '') do
|
||||||
|
get :show,
|
||||||
|
params: { project_id: 1, id: 'Another_page' }
|
||||||
|
|
||||||
get :show,
|
assert_response :success
|
||||||
params: { project_id: 1, id: 'Another_page' }
|
assert_select 'div#wiki_extentions_footer', count: 0
|
||||||
|
end
|
||||||
assert_response :success
|
|
||||||
assert_select 'div#wiki_extentions_footer', count: 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -42,61 +42,61 @@ module ApiTest
|
|||||||
with_additionals_settings(issue_status_change: '0',
|
with_additionals_settings(issue_status_change: '0',
|
||||||
issue_auto_assign: '0',
|
issue_auto_assign: '0',
|
||||||
issue_auto_assign_status: ['1'],
|
issue_auto_assign_status: ['1'],
|
||||||
issue_auto_assign_role: '1')
|
issue_auto_assign_role: '1') do
|
||||||
|
payload = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<issue>
|
||||||
|
<project_id>1</project_id>
|
||||||
|
<tracker_id>2</tracker_id>
|
||||||
|
<status_id>3</status_id>
|
||||||
|
<subject>API test</subject>
|
||||||
|
</issue>
|
||||||
|
XML
|
||||||
|
|
||||||
payload = <<-XML
|
assert_difference('Issue.count') do
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
post '/issues.xml',
|
||||||
<issue>
|
params: payload,
|
||||||
<project_id>1</project_id>
|
headers: { 'CONTENT_TYPE' => 'application/xml' }.merge(credentials('jsmith'))
|
||||||
<tracker_id>2</tracker_id>
|
end
|
||||||
<status_id>3</status_id>
|
issue = Issue.order(id: :desc).first
|
||||||
<subject>API test</subject>
|
assert_equal 1, issue.project_id
|
||||||
</issue>
|
assert_nil issue.assigned_to_id
|
||||||
XML
|
assert_equal 'API test', issue.subject
|
||||||
|
|
||||||
assert_difference('Issue.count') do
|
assert_response :created
|
||||||
post '/issues.xml',
|
assert_equal 'application/xml', @response.content_type
|
||||||
params: payload,
|
assert_select 'issue > id', text: issue.id.to_s
|
||||||
headers: { 'CONTENT_TYPE' => 'application/xml' }.merge(credentials('jsmith'))
|
|
||||||
end
|
end
|
||||||
issue = Issue.order(id: :desc).first
|
|
||||||
assert_equal 1, issue.project_id
|
|
||||||
assert_nil issue.assigned_to_id
|
|
||||||
assert_equal 'API test', issue.subject
|
|
||||||
|
|
||||||
assert_response :created
|
|
||||||
assert_equal 'application/xml', @response.content_type
|
|
||||||
assert_select 'issue > id', text: issue.id.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'POST /issues.xml should create an issue with auto assigned_to_id' do
|
test 'POST /issues.xml should create an issue with auto assigned_to_id' do
|
||||||
with_additionals_settings(issue_status_change: '0',
|
with_additionals_settings(issue_status_change: '0',
|
||||||
issue_auto_assign: '1',
|
issue_auto_assign: '1',
|
||||||
issue_auto_assign_status: ['1'],
|
issue_auto_assign_status: ['1'],
|
||||||
issue_auto_assign_role: '1')
|
issue_auto_assign_role: '1') do
|
||||||
|
payload = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<issue>
|
||||||
|
<project_id>1</project_id>
|
||||||
|
<subject>API test</subject>
|
||||||
|
</issue>
|
||||||
|
XML
|
||||||
|
|
||||||
payload = <<-XML
|
assert_difference('Issue.count') do
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
post '/issues.xml',
|
||||||
<issue>
|
params: payload,
|
||||||
<project_id>1</project_id>
|
headers: { 'CONTENT_TYPE' => 'application/xml' }.merge(credentials('jsmith'))
|
||||||
<subject>API test</subject>
|
end
|
||||||
</issue>
|
|
||||||
XML
|
|
||||||
|
|
||||||
assert_difference('Issue.count') do
|
issue = Issue.order(id: :desc).first
|
||||||
post '/issues.xml',
|
assert_equal 1, issue.project_id
|
||||||
params: payload,
|
assert_equal 2, issue.assigned_to_id
|
||||||
headers: { 'CONTENT_TYPE' => 'application/xml' }.merge(credentials('jsmith'))
|
assert_equal 'API test', issue.subject
|
||||||
|
|
||||||
|
assert_response :created
|
||||||
|
assert_equal 'application/xml', @response.content_type
|
||||||
|
assert_select 'issue > id', text: issue.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
issue = Issue.order(id: :desc).first
|
|
||||||
assert_equal 1, issue.project_id
|
|
||||||
assert_equal 2, issue.assigned_to_id
|
|
||||||
assert_equal 'API test', issue.subject
|
|
||||||
|
|
||||||
assert_response :created
|
|
||||||
assert_equal 'application/xml', @response.content_type
|
|
||||||
assert_select 'issue > id', text: issue.id.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'DELETE /issues/:id.xml' do
|
test 'DELETE /issues/:id.xml' do
|
||||||
|
@ -17,8 +17,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
|
|||||||
|
|
||||||
module Additionals
|
module Additionals
|
||||||
module TestHelper
|
module TestHelper
|
||||||
def with_additionals_settings(settings)
|
def with_additionals_settings(settings, &_block)
|
||||||
Additionals.change_settings = settings
|
Additionals.change_settings = settings
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
Additionals.change_settings = Setting[:plugin_additionals]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,21 +67,21 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
with_additionals_settings(issue_status_change: '0',
|
with_additionals_settings(issue_status_change: '0',
|
||||||
issue_auto_assign: '1',
|
issue_auto_assign: '1',
|
||||||
issue_auto_assign_status: ['1'],
|
issue_auto_assign_status: ['1'],
|
||||||
issue_auto_assign_role: '1')
|
issue_auto_assign_role: '1') do
|
||||||
|
issue = Issue.new(project_id: 1, tracker_id: 1, author_id: 3, subject: 'test_create')
|
||||||
issue = Issue.new(project_id: 1, tracker_id: 1, author_id: 3, subject: 'test_create')
|
assert issue.save
|
||||||
assert issue.save
|
assert_equal 2, issue.assigned_to_id
|
||||||
assert_equal 2, issue.assigned_to_id
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_disabled_auto_assigned_to
|
def test_disabled_auto_assigned_to
|
||||||
with_additionals_settings(issue_status_change: '0',
|
with_additionals_settings(issue_status_change: '0',
|
||||||
issue_auto_assign: '0',
|
issue_auto_assign: '0',
|
||||||
issue_auto_assign_status: ['1'],
|
issue_auto_assign_status: ['1'],
|
||||||
issue_auto_assign_role: '1')
|
issue_auto_assign_role: '1') do
|
||||||
|
issue = Issue.new(project_id: 1, tracker_id: 1, author_id: 3, subject: 'test_create')
|
||||||
issue = Issue.new(project_id: 1, tracker_id: 1, author_id: 3, subject: 'test_create')
|
assert issue.save
|
||||||
assert issue.save
|
assert_nil issue.assigned_to_id
|
||||||
assert_nil issue.assigned_to_id
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,83 +11,93 @@ class WatcherTest < ActiveSupport::TestCase
|
|||||||
@author = User.find(1)
|
@author = User.find(1)
|
||||||
@assigned_user = User.find(2)
|
@assigned_user = User.find(2)
|
||||||
@changing_user = User.find(4)
|
@changing_user = User.find(4)
|
||||||
with_additionals_settings(issue_autowatch_involved: 1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_issue_with_no_autowatch
|
def test_new_issue_with_no_autowatch
|
||||||
with_additionals_settings(issue_autowatch_involved: 0)
|
with_additionals_settings(issue_autowatch_involved: 0) do
|
||||||
User.current = @author
|
User.current = @author
|
||||||
issue = Issue.generate(author_id: @author.id)
|
issue = Issue.generate(author_id: @author.id)
|
||||||
issue.save
|
issue.save
|
||||||
assert_equal 0, issue.watchers.count
|
assert_equal 0, issue.watchers.count
|
||||||
assert_not issue.watched_by?(@author)
|
assert_not issue.watched_by?(@author)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_issue_with_no_autowatch_by_user
|
def test_new_issue_with_no_autowatch_by_user
|
||||||
User.current = @author
|
with_additionals_settings(issue_autowatch_involved: 1) do
|
||||||
User.current.pref.update_attribute :autowatch_involved_issue, false
|
User.current = @author
|
||||||
|
User.current.pref.update_attribute :autowatch_involved_issue, false
|
||||||
|
|
||||||
issue = Issue.generate(author_id: @author.id)
|
issue = Issue.generate(author_id: @author.id)
|
||||||
issue.save
|
issue.save
|
||||||
assert_equal 0, issue.watchers.count
|
assert_equal 0, issue.watchers.count
|
||||||
assert_not issue.watched_by?(@author)
|
assert_not issue.watched_by?(@author)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_issue_with_author_watch_only
|
def test_new_issue_with_author_watch_only
|
||||||
User.current = @author
|
with_additionals_settings(issue_autowatch_involved: 1) do
|
||||||
issue = Issue.generate(author_id: @author.id)
|
User.current = @author
|
||||||
issue.save
|
issue = Issue.generate(author_id: @author.id)
|
||||||
assert_equal 1, issue.watchers.count
|
issue.save
|
||||||
assert issue.watched_by?(@author)
|
assert_equal 1, issue.watchers.count
|
||||||
|
assert issue.watched_by?(@author)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_issue_with_author_and_assigned_to_watchers
|
def test_new_issue_with_author_and_assigned_to_watchers
|
||||||
User.current = @author
|
with_additionals_settings(issue_autowatch_involved: 1) do
|
||||||
issue = Issue.generate(author_id: @author.id, assigned_to: @assigned_user)
|
User.current = @author
|
||||||
issue.save
|
issue = Issue.generate(author_id: @author.id, assigned_to: @assigned_user)
|
||||||
|
issue.save
|
||||||
|
|
||||||
assert_equal 2, issue.watchers.count
|
assert_equal 2, issue.watchers.count
|
||||||
assert issue.watched_by?(@author)
|
assert issue.watched_by?(@author)
|
||||||
assert issue.watched_by?(@assigned_user)
|
assert issue.watched_by?(@assigned_user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issue_do_not_add_author_with_user_change
|
def test_issue_do_not_add_author_with_user_change
|
||||||
User.current = @author
|
with_additionals_settings(issue_autowatch_involved: 1) do
|
||||||
|
User.current = @author
|
||||||
|
|
||||||
issue = Issue.generate(author_id: @author.id, assigned_to: @assigned_user)
|
issue = Issue.generate(author_id: @author.id, assigned_to: @assigned_user)
|
||||||
issue.save
|
issue.save
|
||||||
assert_equal 2, issue.watchers.count
|
assert_equal 2, issue.watchers.count
|
||||||
|
|
||||||
issue.remove_watcher(@author)
|
issue.remove_watcher(@author)
|
||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 1, issue.watchers.count
|
assert_equal 1, issue.watchers.count
|
||||||
|
|
||||||
User.current = @changing_user
|
User.current = @changing_user
|
||||||
issue.subject = 'Changing....'
|
issue.subject = 'Changing....'
|
||||||
issue.save
|
issue.save
|
||||||
|
|
||||||
assert_equal 2, issue.watchers.count
|
assert_equal 2, issue.watchers.count
|
||||||
assert issue.watched_by?(@changing_user)
|
assert issue.watched_by?(@changing_user)
|
||||||
assert issue.watched_by?(@assigned_user)
|
assert issue.watched_by?(@assigned_user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issue_do_not_add_assigned_to_with_user_change
|
def test_issue_do_not_add_assigned_to_with_user_change
|
||||||
User.current = @author
|
with_additionals_settings(issue_autowatch_involved: 1) do
|
||||||
|
User.current = @author
|
||||||
|
|
||||||
issue = Issue.generate(author_id: @author.id, assigned_to: @assigned_user)
|
issue = Issue.generate(author_id: @author.id, assigned_to: @assigned_user)
|
||||||
issue.save
|
issue.save
|
||||||
assert_equal 2, issue.watchers.count
|
assert_equal 2, issue.watchers.count
|
||||||
|
|
||||||
issue.remove_watcher(@assigned_user)
|
issue.remove_watcher(@assigned_user)
|
||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 1, issue.watchers.count
|
assert_equal 1, issue.watchers.count
|
||||||
|
|
||||||
User.current = @changing_user
|
User.current = @changing_user
|
||||||
issue.subject = 'Changing....'
|
issue.subject = 'Changing....'
|
||||||
issue.save
|
issue.save
|
||||||
|
|
||||||
assert_equal 2, issue.watchers.count
|
assert_equal 2, issue.watchers.count
|
||||||
assert issue.watched_by?(@author)
|
assert issue.watched_by?(@author)
|
||||||
assert issue.watched_by?(@changing_user)
|
assert issue.watched_by?(@changing_user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user