Nuevo plugin Additionals 2.0.20

This commit is contained in:
Manuel Cillero 2019-06-16 12:53:09 +02:00
parent a2a901b71b
commit 93e1e28683
354 changed files with 40514 additions and 0 deletions

View file

@ -0,0 +1,53 @@
require File.expand_path('../../test_helper', __FILE__)
class AccountControllerTest < Additionals::ControllerTest
fixtures :users, :email_addresses, :roles
def setup
Setting.default_language = 'en'
User.current = nil
end
def test_get_login_with_welcome_text
with_additionals_settings(account_login_bottom: 'Lore impsuum') do
get :login
assert_response :success
assert_select 'input[name=username]'
assert_select 'input[name=password]'
assert_select 'div.login-additionals', text: /Lore impsuum/
end
end
def test_get_login_without_welcome_text
with_additionals_settings(account_login_bottom: '') do
get :login
assert_response :success
assert_select 'input[name=username]'
assert_select 'input[name=password]'
assert_select 'div.login-additionals', count: 0
end
end
# See integration/account_test.rb for the full test
def test_post_register_with_registration_on
with_settings self_registration: '3' do
assert_difference 'User.count' do
post :register,
params: { user: { login: 'register',
password: 'secret123',
password_confirmation: 'secret123',
firstname: 'John',
lastname: 'Doe',
mail: 'register@example.com' } }
assert_redirected_to '/my/account'
end
user = User.order(id: :desc).first
assert_equal 'register', user.login
assert_equal 'John', user.firstname
assert_equal 'Doe', user.lastname
assert_equal 'register@example.com', user.mail
assert user.check_password?('secret123')
assert user.active?
end
end
end

View file

@ -0,0 +1,44 @@
require File.expand_path('../../test_helper', __FILE__)
class AdditionalsAssignToMeControllerTest < Additionals::ControllerTest
fixtures :projects,
:users, :email_addresses, :user_preferences,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:issue_relations,
: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
test 'assign issue to user' do
session[:user_id] = 2
assert_difference('Journal.count') do
put :update,
params: { issue_id: 1 }
end
end
test 'no update for issue, which already same user is assigned' do
session[:user_id] = 3
assert_no_difference('Journal.count') do
put :update,
params: { issue_id: 2 }
end
end
end

View file

@ -0,0 +1,44 @@
require File.expand_path('../../test_helper', __FILE__)
class AdditionalsChangeStatusControllerTest < Additionals::ControllerTest
fixtures :projects,
:users, :email_addresses, :user_preferences,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:issue_relations,
: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
test 'assign new status to issue' do
session[:user_id] = 2
assert_difference('Journal.count') do
put :update,
params: { issue_id: 4, new_status_id: 3 }
end
end
test 'no update for issue, which already has same status' do
session[:user_id] = 2
assert_no_difference('Journal.count') do
put :update,
params: { issue_id: 2, new_status_id: 2 }
end
end
end

View file

@ -0,0 +1,29 @@
require File.expand_path('../../test_helper', __FILE__)
class AdditionalsMacrosControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:enabled_modules
def setup
prepare_tests
end
def test_show
@request.session[:user_id] = 2
get :show
assert_response :success
assert_select 'div.macro-box'
end
def test_show_no_allowed_for_guests
@request.session[:user_id] = nil
get :show
assert_response 302
end
end

View file

@ -0,0 +1,184 @@
require File.expand_path('../../test_helper', __FILE__)
class IssuesControllerTest < Additionals::ControllerTest
fixtures :projects,
:users, :email_addresses, :user_preferences,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:issue_relations,
: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
def setup
manager_role = roles(:roles_001)
manager_role.add_permission!(:edit_issue_author)
end
test 'author field as authorized user in new with change' do
manager_role = roles(:roles_001)
manager_role.add_permission!(:change_new_issue_author)
session[:user_id] = 2
get :new,
params: { project_id: 1 }
assert_select '#issue_tracker_id', true
assert_select '#issue_author_id', true
end
test 'author field as authorized user in new without change' do
session[:user_id] = 2
get :new,
params: { project_id: 1 }
assert_select '#issue_tracker_id', true
assert_select '#issue_author_id', false
end
test 'author field as authorized user in edit' do
session[:user_id] = 2
get :edit,
params: { id: 1 }
assert_select '#issue_author_id'
end
test 'author field as unauthorized user in edit' do
session[:user_id] = 3
get :edit,
params: { id: 1 }
assert_select '#issue_author_id', false
end
test 'update author as authorized user' do
session[:user_id] = 2
assert_difference('Journal.count') do
put :update,
params: { id: 1, issue: { author_id: 1 } }
end
end
test 'update author as unauthorized user' do
session[:user_id] = 3
assert_no_difference('Journal.count') do
put :update,
params: { id: 1, issue: { author_id: 3 } }
end
end
test 'show assign-to-me on issue' do
with_additionals_settings(issue_assign_to_me: 1) do
@request.session[:user_id] = 2
get :show,
params: { id: 2 }
assert_select 'a.assign-to-me'
end
end
test 'don\'t show assign-to-me on issue without activation' do
with_additionals_settings(issue_assign_to_me: 0) do
@request.session[:user_id] = 2
get :show,
params: { id: 2 }
assert_select 'a.assign-to-me', count: 0
end
end
test 'don\'t show assign-to-me on issue with already assigned_to me' do
with_additionals_settings(issue_assign_to_me: 1) do
@request.session[:user_id] = 2
get :show,
params: { id: 4 }
assert_select 'a.assign-to-me', count: 0
end
end
test 'show change status in issue sidebar' do
with_additionals_settings(issue_change_status_in_sidebar: 1) do
@request.session[:user_id] = 2
get :show,
params: { id: 2 }
assert_select 'ul.issue-status-change-sidebar'
end
end
test 'don\'t show change status in issue sidebar without activation' do
with_additionals_settings(issue_change_status_in_sidebar: 0) do
@request.session[:user_id] = 2
get :show,
params: { id: 2 }
assert_select 'ul.issue-status-change-sidebar', count: 0
end
end
test 'don\'t show forbidden status in issue sidebar without timelog' do
with_additionals_settings(issue_change_status_in_sidebar: 1,
issue_timelog_required: 1,
issue_timelog_required_tracker: ['1'],
issue_timelog_required_status: ['5']) do
@request.session[:user_id] = 2
issue = Issue.generate!(tracker_id: 1, status_id: 1)
get :show,
params: { id: issue.id }
assert_response :success
assert_select 'ul.issue-status-change-sidebar a.status-switch.status-4'
assert_select 'ul.issue-status-change-sidebar a.status-switch.status-5', count: 0
end
end
test 'show forbidden status in issue sidebar if disabled' do
with_additionals_settings(issue_change_status_in_sidebar: 1,
issue_timelog_required: 0,
issue_timelog_required_tracker: [1],
issue_timelog_required_status: [5]) do
@request.session[:user_id] = 2
issue = Issue.generate!(tracker_id: 1, status_id: 1)
get :show,
params: { id: issue.id }
assert_response :success
assert_select 'ul.issue-status-change-sidebar a.status-switch.status-4'
assert_select 'ul.issue-status-change-sidebar a.status-switch.status-5'
end
end
test 'show forbidden status in issue sidebar with permission issue_timelog_never_required' do
manager_role = roles(:roles_002)
manager_role.add_permission!(:issue_timelog_never_required)
with_additionals_settings(issue_change_status_in_sidebar: 1,
issue_timelog_required: 1,
issue_timelog_required_tracker: [1],
issue_timelog_required_status: [5]) do
@request.session[:user_id] = 2
issue = Issue.generate!(tracker_id: 1, status_id: 1)
get :show,
params: { id: issue.id }
assert_response :success
assert_select 'ul.issue-status-change-sidebar a.status-switch.status-4'
assert_select 'ul.issue-status-change-sidebar a.status-switch.status-5'
end
end
end

View file

@ -0,0 +1,43 @@
require File.expand_path('../../test_helper', __FILE__)
class ProjectsControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules
def setup
Setting.default_language = 'en'
User.current = nil
end
def test_show_overview_content
with_additionals_settings(project_overview_content: 'Lore impsuum') do
@request.session[:user_id] = 4
get :show,
params: { id: 1 }
assert_response :success
assert_select 'div.project-content', text: /Lore impsuum/
end
end
def test_do_not_show_overview_content_box
with_additionals_settings(project_overview_content: '') do
@request.session[:user_id] = 4
get :show,
params: { id: 1 }
assert_response :success
assert_select 'div.project-content', count: 0
end
end
end

View file

@ -0,0 +1,42 @@
require File.expand_path('../../test_helper', __FILE__)
class UsersControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules
include Redmine::I18n
def setup
prepare_tests
@controller = UsersController.new
User.current = nil
end
def test_show_new_issue_on_profile
with_additionals_settings(new_issue_on_profile: 1) do
@request.session[:user_id] = 2
get :show,
params: { id: 2 }
assert_select 'a.user-new-issue'
end
end
def test_not_show_new_issue_on_profile_without_activated
with_additionals_settings(new_issue_on_profile: 0) do
@request.session[:user_id] = 2
get :show,
params: { id: 2 }
assert_select 'a.user-new-issue', count: 0
end
end
end

View file

@ -0,0 +1,88 @@
require File.expand_path('../../test_helper', __FILE__)
class WelcomeControllerTest < Additionals::ControllerTest
fixtures :projects, :news, :users, :members
def setup
Setting.default_language = 'en'
User.current = nil
end
def test_show_with_overview_right
with_additionals_settings(overview_right: 'Lore impsuum') do
@request.session[:user_id] = 4
get :index
assert_response :success
assert_select 'div.overview-right', text: /Lore impsuum/
end
end
def test_show_without_overview_right
with_additionals_settings(overview_right: '') do
@request.session[:user_id] = 4
get :index
assert_response :success
assert_select 'div.overview-right', count: 0
end
end
def test_show_with_overview_bottom
with_additionals_settings(overview_bottom: 'Lore impsuum') do
@request.session[:user_id] = 4
get :index
assert_response :success
assert_select 'div.overview-bottom', text: /Lore impsuum/
end
end
def test_show_without_overview_bottom
with_additionals_settings(overview_bottom: '') do
@request.session[:user_id] = 4
get :index
assert_response :success
assert_select 'div.overview-bottom', count: 0
end
end
def test_show_with_overview_top
with_additionals_settings(overview_top: 'Lore impsuum') do
@request.session[:user_id] = 4
get :index
assert_response :success
assert_select 'div.overview-top', text: /Lore impsuum/
end
end
def test_show_without_overview_top
with_additionals_settings(overview_top: '') do
@request.session[:user_id] = 4
get :index
assert_response :success
assert_select 'div.overview-top', count: 0
end
end
def test_show_index_with_help_menu
with_additionals_settings(remove_help: 0) do
@request.session[:user_id] = 1
get :index
assert_select 'div#top-menu a.help'
end
end
def test_show_index_without_help_menu
with_additionals_settings(remove_help: 1) do
@request.session[:user_id] = 1
get :index
assert_select 'div#top-menu a.help', count: 0
end
end
end

View file

@ -0,0 +1,511 @@
require File.expand_path('../../test_helper', __FILE__)
class WikiControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:trackers,
:groups_users,
:projects_trackers,
:enabled_modules,
:issue_statuses,
:issues,
:enumerations,
:custom_fields,
:custom_values,
:custom_fields_trackers,
:wikis,
:wiki_pages,
:wiki_contents
WIKI_MACRO_USER_ID = 2
def setup
prepare_tests
EnabledModule.create(project_id: 1, name: 'wiki')
@project = projects(:projects_001)
@wiki = @project.wiki
@page_name = 'additionals_macro_test'
@page = @wiki.find_or_new_page(@page_name)
@page.content = WikiContent.new
@page.content.text = 'test'
@page.save!
end
def test_show_with_youtube_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{youtube(KMU0tzLwhbE)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'iframe[src=?]', '//www.youtube-nocookie.com/embed/KMU0tzLwhbE'
end
def test_show_with_meteoblue_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{meteoblue(münchen_deutschland_2867714)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'iframe', src: %r{^https\://www\.meteoblue\.com/en/weather/widget/daily/(.*)}
end
def test_show_with_vimeo_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{vimeo(142849533)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'iframe[src=?]', '//player.vimeo.com/video/142849533'
end
def test_show_with_slideshare_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{slideshare(57941706)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'iframe[src=?]', '//www.slideshare.net/slideshow/embed_code/57941706'
end
def test_show_with_iframe_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{iframe(https://www.redmine.org/)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'iframe[src=?]', 'https://www.redmine.org/'
end
def test_show_with_twitter_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{twitter(alphanodes)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a.twitter'
assert_select 'a[href=?]', 'https://twitter.com/alphanodes',
text: '@alphanodes'
@page.content.text = '{{twitter(@alphanodes)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_select 'a.twitter'
assert_select 'a[href=?]', 'https://twitter.com/alphanodes',
text: '@alphanodes'
@page.content.text = '{{twitter(#alphanodes)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_select 'a.twitter'
assert_select 'a[href=?]', 'https://twitter.com/hashtag/alphanodes',
text: '#alphanodes'
end
def test_show_with_reddit_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{reddit(redmine)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a.reddit'
assert_select 'a[href=?]', 'https://www.reddit.com/r/redmine',
text: 'r/redmine'
@page.content.text = '{{reddit(u/redmine)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_select 'a.reddit'
assert_select 'a[href=?]', 'https://www.reddit.com/username/redmine',
text: 'u/redmine'
@page.content.text = '{{reddit(r/redmine)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_select 'a.reddit'
assert_select 'a[href=?]', 'https://www.reddit.com/r/redmine',
text: 'r/redmine'
end
def test_show_last_updated_by_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{last_updated_by}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'span.last-updated-by'
assert_select 'a[href=?]', '/users/2',
text: 'jsmith'
end
def test_show_last_updated_at_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{last_updated_at}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'span.last-updated-at'
assert_select 'a[href=?]', '/projects/ecookbook/activity'
end
def test_show_recently_updated_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{recently_updated}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.recently-updated'
end
def test_show_calendar_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{calendar(year=1970, month=7)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.month-calendar'
end
def test_show_with_members_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{members}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.wiki div.user'
end
def test_show_with_new_issue_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{new_issue}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.wiki a.macro-new-issue'
end
def test_show_with_group_users_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{group_users(A Team)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.wiki div.user'
end
def test_show_with_projects_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{projects}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.wiki div.additionals-projects li.project'
end
def test_show_with_fa_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{fa(adjust)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'i.fas.fa-adjust'
end
def test_show_with_redmine_issue_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{redmine_issue(12066)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', 'https://www.redmine.org/issues/12066'
end
def test_show_with_redmine_issue_with_absolute_url_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{redmine_issue(http://www.redmine.org/issues/12066)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', 'https://www.redmine.org/issues/12066'
end
def test_show_with_redmine_wiki_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{redmine_wiki(RedmineInstall)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', 'https://www.redmine.org/projects/redmine/wiki/RedmineInstall'
end
def test_show_with_redmine_wiki_with_absolute_url_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{redmine_wiki(http://www.redmine.org/projects/redmine/wiki/RedmineInstall)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', 'https://www.redmine.org/projects/redmine/wiki/RedmineInstall'
end
def test_show_with_gist_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{gist(plentz/6737338)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'script[src=?]', 'https://gist.github.com/plentz/6737338.js'
end
def test_show_with_tradeview_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{tradingview(symbol=NASDAQ:AMZN, locale=en)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'script[src=?]', 'https://s3.tradingview.com/tv.js'
end
def test_show_with_cryptocompare_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{cryptocompare(fsyms=BTC;ETH, type=header_v3)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.wiki div.cryptocompare',
text: %r{https:\/\/widgets\.cryptocompare\.com\/serve\/v3\/coin\/header\?fsyms=BTC,ETH&tsyms=EUR}
end
def test_show_with_date_macro
@request.session[:user_id] = WIKI_MACRO_USER_ID
valid_types = %w[current_date current_date_with_time current_year
current_month current_day current_hour current_minute
current_weekday current_weeknumber]
@page.content.text = ''
valid_types.each do |type|
@page.content.text << "{{date(#{type})}}"
end
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.wiki', html: /{{date/, count: 0
assert_select 'div.wiki span.current-date', count: valid_types.count
assert_select 'div.wiki span.current-date', User.current.today.cweek.to_s
assert_select 'div.flash.error', html: /Error executing/, count: 0
end
def test_show_with_date_macro_and_invalid_type
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{date(invalid_type_name)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.flash.error', html: /Error executing/
end
def test_show_with_date_macro_custom_date
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{date(2017-02-25)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.flash.error', html: /Error executing/, count: 0
end
def test_show_with_date_macro_invalid_custom_date
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{date(2017-02-30)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'div.flash.error', html: /Error executing/
end
def test_show_issue
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{issue(2, format=short)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', '/issues/2',
text: 'Add ingredients categories'
end
def test_show_issue_with_id
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{issue(2, format=link)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', '/issues/2',
text: '#2 Add ingredients categories'
end
def test_show_issue_with_url
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{issue(http://test.host/issues/2)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', '/issues/2',
text: '#2 Add ingredients categories'
assert_select 'div.issue-macro-comment', 0
end
def test_show_issue_and_comment_with_url
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{issue(http://test.host/issues/2#note-1)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', '/issues/2',
text: '#2 Add ingredients categories'
assert_select 'div.issue-macro-comment'
end
def test_show_issue_with_id_default
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{issue(2)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', '/issues/2',
text: '#2 Add ingredients categories'
end
def test_show_user_with_id
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{user(1)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', '/users/1',
text: 'Redmine Admin'
end
def test_show_user_with_id_fullname
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{user(1, format=firstname_lastname)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a.user', text: 'Redmine Admin'
assert_select 'a[href=?]', '/users/1',
text: 'Redmine Admin'
end
def test_show_user_with_name
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{user(jsmith)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a[href=?]', '/users/2',
text: 'jsmith'
end
def test_show_user_with_name_fullname
@request.session[:user_id] = WIKI_MACRO_USER_ID
@page.content.text = '{{user(jsmith, format=firstname_lastname, avatar=true)}}'
@page.content.save!
get :show,
params: { project_id: 1, id: @page_name }
assert_response :success
assert_select 'a.user', text: 'John Smith'
assert_select 'a[href=?]', '/users/2',
text: 'John Smith'
end
def test_show_wiki_with_header
with_additionals_settings(global_wiki_header: 'Lore impsuum') do
get :show,
params: { project_id: 1, id: 'Another_page' }
assert_response :success
assert_select 'div#wiki_extentions_header', text: /Lore impsuum/
end
end
def test_show_wiki_without_header
with_additionals_settings(global_wiki_header: '') do
get :show,
params: { project_id: 1, id: 'Another_page' }
assert_response :success
assert_select 'div#wiki_extentions_header', count: 0
end
end
def test_show_wiki_with_footer
with_additionals_settings(global_wiki_footer: 'Lore impsuum') do
get :show,
params: { project_id: 1, id: 'Another_page' }
assert_response :success
assert_select 'div#wiki_extentions_footer', text: /Lore impsuum/
end
end
def test_show_wiki_without_footer
with_additionals_settings(global_wiki_footer: '') do
get :show,
params: { project_id: 1, id: 'Another_page' }
assert_response :success
assert_select 'div#wiki_extentions_footer', count: 0
end
end
end