1
0
This repository has been archived on 2023-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
body_tracking/test/application_system_test_case.rb
cryptogopher 1b7f2f0abd Added test_defaults_seed_and_load_into_empty_project
Added :defaults scopes to models
Added :sources and :formulas fixtures
Loading defaults from seeds.rb using rake task instead of migration
2020-08-29 01:26:36 +02:00

99 lines
3.3 KiB
Ruby

# Required for Puma to start in test env for system tests
# (RAILS_ENV=test does not work)
ENV["RACK_ENV"] = "test"
# Load the Redmine helper
require File.expand_path('../../../../test/application_system_test_case', __FILE__)
class BodyTrackingSystemTestCase < ApplicationSystemTestCase
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.dir'] = DOWNLOADS_PATH
profile['browser.download.folderList'] = 2
profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf"
profile['pdfjs.disabled'] = true
driven_by :selenium, using: :headless_firefox, screen_size: [1280, 720], options: {
profile: profile
}
Capybara.configure do |config|
config.save_path = Rails.root.join('tmp', 'screenshots')
FileUtils.rm Dir.glob(File.join(config.save_path, '*.png'))
end
fixtures :projects, :users, :members
# Redmine fixtures use explicit IDs, so it's impossible to access them by name.
# Use: 'project_id: 1' and NOT 'project: projects_001'
plugin_fixtures :enabled_modules, :roles, :member_roles,
:sources, :quantities, :units, :formulas, :goals, :exposures, :targets, :quantity_values
include AbstractController::Translation
def logout_user
click_link t(:label_logout)
assert_current_path home_path
assert_link t(:label_login)
end
def create_recurrence(issue=issues(:issue_01), **attributes)
#attributes[:mode] ||= :weekly
t_base = 'issues.recurrences.form'
visit issue_path(issue)
assert_difference ['all("#recurrences tr").length', 'IssueRecurrence.count'], 1 do
within '#issue_recurrences' do
click_link t(:button_add)
attributes.each do |k, v|
value = case k
when :mode
interval = t("#{t_base}.mode_intervals.#{v}")
description = t("#{t_base}.mode_descriptions.#{v}")
"#{interval}(s)" + (description.present? ? ", #{description}" : '')
when :anchor_to_start
t("#{t_base}.#{k.to_s}.#{v}")
else
t("#{t_base}.#{k.to_s.pluralize}.#{v}")
end
select strip_tags(value), from: "recurrence_#{k}"
end
click_button t(:button_add)
end
# status_code not supported by Selenium
assert_current_path issue_path(issue)
assert_selector '#recurrence-errors', visible: :all, exact_text: ''
end
IssueRecurrence.last
end
def destroy_recurrence(recurrence)
visit issue_path(recurrence.issue)
assert_difference ['all("#recurrences tr").length', 'IssueRecurrence.count'], -1 do
within "#recurrences tr[id=recurrence-#{recurrence.id}]" do
click_link t(:button_delete)
end
# status_code not supported by Selenium
assert_current_path issue_path(recurrence.issue)
assert_selector '#recurrence-errors', visible: :all, exact_text: ''
end
end
def close_issue(issue)
assert !issue.closed?
closed_on = issue.closed_on
status = IssueStatus.all.where(is_closed: true).first
visit edit_issue_path(issue)
within 'form#issue-form' do
select status.name, from: t(:field_status)
click_button t(:button_submit)
end
issue.reload
assert_equal status.id, issue.status_id
assert_not_nil issue.closed_on
assert_not_equal closed_on, issue.closed_on
assert issue.closed?
end
end