mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-22 14:54:38 +08:00
Merge pull request #2385 from okriuchykhin/ok_SCI_4317
Add explicit ordering of items for repository columns [SCI-4317]
This commit is contained in:
commit
b361865706
3 changed files with 14 additions and 7 deletions
|
@ -5,9 +5,15 @@ class RepositoryColumn < ApplicationRecord
|
|||
belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User'
|
||||
has_many :repository_cells, dependent: :destroy
|
||||
has_many :repository_rows, through: :repository_cells
|
||||
has_many :repository_list_items, dependent: :destroy, index_errors: true
|
||||
has_many :repository_status_items, dependent: :destroy, index_errors: true
|
||||
has_many :repository_checklist_items, dependent: :destroy, index_errors: true
|
||||
has_many :repository_list_items, -> { order('data ASC') }, dependent: :destroy,
|
||||
index_errors: true,
|
||||
inverse_of: :repository_column
|
||||
has_many :repository_status_items, -> { order('status ASC') }, dependent: :destroy,
|
||||
index_errors: true,
|
||||
inverse_of: :repository_column
|
||||
has_many :repository_checklist_items, -> { order('data ASC') }, dependent: :destroy,
|
||||
index_errors: true,
|
||||
inverse_of: :repository_column
|
||||
|
||||
accepts_nested_attributes_for :repository_status_items, allow_destroy: true
|
||||
accepts_nested_attributes_for :repository_list_items, allow_destroy: true
|
||||
|
|
|
@ -265,8 +265,9 @@ RSpec.describe 'Api::V1::InventoryListItemsController', type: :request do
|
|||
|
||||
it 'Response with correct inventory list item' do
|
||||
hash_body = nil
|
||||
item_id = @list_column.repository_list_items.first.id
|
||||
put api_v1_team_inventory_column_list_item_path(
|
||||
id: @list_column.repository_list_items.first.id,
|
||||
id: item_id,
|
||||
team_id: @teams.first.id,
|
||||
inventory_id: @valid_inventory.id,
|
||||
column_id: @list_column
|
||||
|
@ -275,11 +276,11 @@ RSpec.describe 'Api::V1::InventoryListItemsController', type: :request do
|
|||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body[:data]).to match(
|
||||
ActiveModelSerializers::SerializableResource
|
||||
.new(@list_column.repository_list_items.first,
|
||||
.new(@list_column.repository_list_items.find(item_id),
|
||||
serializer: Api::V1::InventoryListItemSerializer)
|
||||
.as_json[:data]
|
||||
)
|
||||
expect(@list_column.repository_list_items.first.data).to match('Updated')
|
||||
expect(@list_column.repository_list_items.find(item_id).data).to match('Updated')
|
||||
end
|
||||
|
||||
it 'When invalid request, incorrect type' do
|
||||
|
|
|
@ -7,7 +7,7 @@ describe RepositoryColumns::CreateColumnService do
|
|||
let!(:user_team) { create :user_team, :admin, user: user, team: team }
|
||||
let(:team) { create :team }
|
||||
let(:repository) { create :repository, team: team }
|
||||
let(:column_type) { :RepositoryListValue }
|
||||
let(:column_type) { :RepositoryStatusValue }
|
||||
let(:params) do
|
||||
{
|
||||
name: 'myrepo',
|
||||
|
|
Loading…
Reference in a new issue