pull/7473/head
Oliver Günther 5 years ago
parent b2505245ff
commit 285bd3ec20
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 5
      app/seeders/demo_data/work_package_board_seeder.rb
  2. 2
      frontend/src/app/components/table-pagination/table-pagination.component.ts
  3. 1
      frontend/src/app/components/wp-table/table-pagination/wp-table-pagination.component.ts
  4. 4
      lib/api/v3/queries/query_representer.rb
  5. 6
      modules/boards/spec/features/action_boards/status_board_spec.rb
  6. 17
      modules/boards/spec/features/action_boards/version_board_spec.rb
  7. 10
      modules/boards/spec/features/board_management_spec.rb
  8. 18
      spec/contracts/queries/update_contract_spec.rb
  9. 4
      spec/lib/api/v3/queries/query_representer_generation_spec.rb
  10. 35
      spec/lib/api/v3/queries/query_representer_parsing_spec.rb

@ -154,7 +154,10 @@ module DemoData
query.add_filter('manual_sort', 'ow', [])
query.sort_criteria = [[:manual_sorting, 'asc']]
query.ordered_work_packages = list[:wps]
list[:wps].each_with_index do |wp_id, i|
query.ordered_work_packages.build(work_package_id: wp_id, position: i)
end
query.save!
end
end

@ -158,7 +158,7 @@ export class TablePaginationComponent implements OnInit {
public showPerPageOptions() {
return !this.calculatePerPage &&
this.perPageOptions.length > 0 &&
this.pagination.total > this.perPageOptions[0]
this.pagination.total > this.perPageOptions[0];
}
private truncatePageNums(pageNumbers:any, perform:any, disectFrom:any, disectLength:any, truncateFrom:any) {

@ -54,6 +54,7 @@ export class WorkPackageTablePaginationComponent extends TablePaginationComponen
.loadPaginationOptions()
.then((paginationOptions:IPaginationOptions) => {
this.perPageOptions = paginationOptions.perPageOptions;
this.cdRef.detectChanges();
});
this.wpTablePagination

@ -260,8 +260,8 @@ module API
setter: ->(fragment:, **) {
next unless represented.new_record?
Hash(fragment).each do |wpId, position|
represented.ordered_work_packages.build(work_package_id: wpId, position: position)
Hash(fragment).each do |wp_id, position|
represented.ordered_work_packages.build(work_package_id: wp_id, position: position)
end
}

@ -124,7 +124,7 @@ describe 'Status action board', type: :feature, js: true do
expect(second.ordered_work_packages).to be_empty
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: first.ordered_work_packages).pluck(:subject, :status_id)
subjects = WorkPackage.where(id: first.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :status_id)
expect(subjects).to match_array [['Task 1', open_status.id]]
# Move item to Closed
@ -139,7 +139,7 @@ describe 'Status action board', type: :feature, js: true do
expect(second.reload.ordered_work_packages.count).to eq(1)
end
subjects = WorkPackage.where(id: second.ordered_work_packages).pluck(:subject, :status_id)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :status_id)
expect(subjects).to match_array [['Task 1', closed_status.id]]
# Try to drag to whatever, which has no workflow
@ -198,7 +198,7 @@ describe 'Status action board', type: :feature, js: true do
expect(queries.last.name).to eq 'Closed'
expect(queries.first.ordered_work_packages).to be_empty
subjects = WorkPackage.where(id: second.ordered_work_packages).pluck(:subject, :status_id)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :status_id)
expect(subjects).to match_array [['Task 1', closed_status.id]]
end
end

@ -132,12 +132,13 @@ describe 'Version action board', type: :feature, js: true do
expect(queries.count).to eq 3
first = queries.find_by(name: 'Open version')
second = queries.find_by(name: 'A second version')
expect(first.ordered_work_packages.count).to eq(2)
expect(first.ordered_work_packages.count).to eq(1)
expect(second.ordered_work_packages).to be_empty
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: first.ordered_work_packages).pluck(:subject, :fixed_version_id)
expect(subjects).to match_array [[work_package.subject, open_version.id],['Task 1', open_version.id]]
subjects = WorkPackage.where(id: first.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :fixed_version_id)
# Only the explicitly added item is now contained in sort order
expect(subjects).to match_array [['Task 1', open_version.id]]
# Move item to Closed
board_page.move_card(0, from: 'Open version', to: 'A second version')
@ -147,11 +148,11 @@ describe 'Version action board', type: :feature, js: true do
# Expect work package to be saved in query second
sleep 2
retry_block do
expect(first.reload.ordered_work_packages.count).to eq(1)
expect(first.reload.ordered_work_packages.count).to eq(0)
expect(second.reload.ordered_work_packages.count).to eq(1)
end
subjects = WorkPackage.where(id: second.ordered_work_packages).pluck(:subject, :fixed_version_id)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :fixed_version_id)
expect(subjects).to match_array [['Task 1', other_version.id]]
# Expect that version is not available for global filter selection
@ -201,7 +202,7 @@ describe 'Version action board', type: :feature, js: true do
board_page.expect_card('Open version', 'Foo', present: false)
board_page.expect_card('A second version', 'Task 1', present: true)
subjects = WorkPackage.where(id: second.ordered_work_packages).pluck(:subject, :fixed_version_id)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :fixed_version_id)
expect(subjects).to match_array [['Task 1', other_version.id]]
end
@ -252,8 +253,8 @@ describe 'Version action board', type: :feature, js: true do
expect(closed.reload.ordered_work_packages.count).to eq(0)
end
subjects = WorkPackage.where(id: open.ordered_work_packages).pluck(:id)
expect(subjects).to match_array [work_package.id, closed_version_wp.id]
ids = open.ordered_work_packages.pluck(:work_package_id)
expect(ids).to match_array [work_package.id, closed_version_wp.id]
closed_version_wp.reload
expect(closed_version_wp.fixed_version_id).to eq(open_version.id)

@ -107,7 +107,7 @@ describe 'Board management spec', type: :feature, js: true do
expect(second.ordered_work_packages).to be_empty
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: first.ordered_work_packages).pluck(:subject)
subjects = WorkPackage.where(id: first.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
expect(subjects).to match_array ['Task 1']
# Move item to Second list
@ -122,7 +122,7 @@ describe 'Board management spec', type: :feature, js: true do
expect(second.reload.ordered_work_packages.count).to eq(1)
end
subjects = WorkPackage.where(id: second.ordered_work_packages).pluck(:subject)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
expect(subjects).to match_array ['Task 1']
# Reference an existing work package
@ -130,7 +130,7 @@ describe 'Board management spec', type: :feature, js: true do
sleep 2
board_page.expect_card('Second', work_package.subject)
subjects = WorkPackage.where(id: second.ordered_work_packages).pluck(:subject)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
expect(subjects).to match_array [work_package.subject, 'Task 1']
# Filter for Task
@ -155,7 +155,7 @@ describe 'Board management spec', type: :feature, js: true do
queries = board_page.board(reload: true).contained_queries
expect(queries.count).to eq(1)
expect(queries.first.name).to eq 'First'
expect(queries.first.ordered_work_packages).to be_empty
expect(queries.first.ordered_work_packages.to_a).to be_empty
# Remove first list
board_page.remove_list 'First'
@ -216,7 +216,7 @@ describe 'Board management spec', type: :feature, js: true do
expect(second.ordered_work_packages.count).to eq(1)
# Expect work package to be saved in query first
subjects = WorkPackage.where(id: second.ordered_work_packages).pluck(:subject)
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject)
expect(subjects).to match_array ['Task 1']
board_page.back_to_index

@ -103,24 +103,6 @@ describe Queries::UpdateContract do
end
end
context 'user has permission to edit' do
let(:permissions) { %i(edit_work_packages) }
it 'is invalid' do
expect_valid(false, base: %i(error_unauthorized))
end
context 'when assuming only order changed' do
before do
query.ordered_work_packages = [1, 2, 3]
end
it 'is valid' do
expect_valid(true)
end
end
end
context 'user has no permission to manage public' do
let(:permissions) { %i(manage_public_queries) }

@ -275,7 +275,7 @@ describe ::API::V3::Queries::QueryRepresenter do
it_behaves_like 'has an untitled link' do
let(:link) { 'updateOrderedWorkPackages' }
let(:href) { api_v3_paths.query query.id }
let(:href) { api_v3_paths.query_order query.id }
end
context 'when not persisted and lacking permission' do
@ -293,7 +293,7 @@ describe ::API::V3::Queries::QueryRepresenter do
it_behaves_like 'has an untitled link' do
let(:link) { 'updateOrderedWorkPackages' }
let(:href) { api_v3_paths.query query.id }
let(:href) { api_v3_paths.query_order query.id }
end
end

@ -104,20 +104,35 @@ describe ::API::V3::Queries::QueryRepresenter do
describe 'parsing ordered work packages' do
let(:request_body) do
{
'orderedWorkPackages' => %w[
/api/v3/work_packages/50
/api/v3/work_packages/38
/api/v3/work_packages/102
]
'orderedWorkPackages' => {
50 => 0,
38 => 1234,
102 => 81234123
}
}
end
it 'should set ordered_work_packages' do
expect(query)
.to receive(:ordered_work_packages=)
.with %w[50 38 102]
before do
allow(query).to receive(:new_record?).and_return(new_record)
end
context 'assuming query is new' do
let(:new_record) { true }
it 'should set ordered_work_packages' do
order = subject.ordered_work_packages.map { |el| [el.work_package_id, el.position] }
expect(order).to match_array [[50, 0], [38, 1234], [102, 81234123]]
end
end
context 'assuming query is not new' do
let(:new_record) { false }
it 'should set ordered_work_packages' do
expect(query)
.not_to receive(:ordered_work_packages)
subject
subject
end
end
end
end

Loading…
Cancel
Save