Add validation and test for include_subprojects

pull/10368/head
Oliver Günther 3 years ago
parent 8aefbc4a5d
commit cb8fac1f14
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 3
      app/models/query.rb
  2. 22
      spec/models/query_spec.rb
  3. 2
      spec/models/work_package/exporter/csv_integration_spec.rb

@ -45,6 +45,9 @@ class Query < ApplicationRecord
presence: true,
length: { maximum: 255 }
validates :include_subprojects,
inclusion: [true, false]
validate :validate_work_package_filters
validate :validate_columns
validate :validate_sort_criteria

@ -60,6 +60,28 @@ describe Query, type: :model do
expect(query.sort_criteria)
.to match_array([['id', 'asc']])
end
context 'with global subprojects include', with_settings: { display_subprojects_work_packages: true } do
it 'sets the include subprojects' do
expect(query.include_subprojects).to eq true
end
end
context 'with global subprojects include', with_settings: { display_subprojects_work_packages: false } do
it 'sets the include subprojects' do
expect(query.include_subprojects).to eq false
end
end
end
describe 'include_subprojects' do
let(:query) { Query.new name: 'foo' }
it 'is required' do
expect(query).not_to be_valid
expect(query.errors[:include_subprojects]).to include 'is not set to one of the allowed values.'
end
end
describe 'hidden' do

@ -41,7 +41,7 @@ describe WorkPackage::Exports::CSV, 'integration', type: :model do
member_with_permissions: %i(view_work_packages))
end
let(:query) do
Query.new(name: '_').tap do |query|
Query.new_default(name: '_').tap do |query|
query.column_names = %i(subject assigned_to updated_at estimated_hours)
end
end

Loading…
Cancel
Save