Skip to content

Commit 3bb518d

Browse files
committed
Add concrete_items association
1 parent d92bcc6 commit 3bb518d

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

app/controllers/adjustments_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def new
3434
@adjustment = current_organization.adjustments.new
3535
@adjustment.line_items.build
3636
@storage_locations = current_organization.storage_locations.active
37-
@items = ConcreteItem.where(organization: current_organization).active.alphabetized
37+
@items = current_organization.concrete_items.active.alphabetized
3838
end
3939

4040
# POST /adjustments
@@ -55,7 +55,7 @@ def create
5555

5656
def load_form_collections
5757
@storage_locations = current_organization.storage_locations.active
58-
@items = ConcreteItem.where(organization: current_organization).alphabetized
58+
@items = current_organization.concrete_items.alphabetized
5959
end
6060

6161
def adjustment_params

app/models/organization.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class Organization < ApplicationRecord
8585
has_many :product_drive_tags, -> { by_type("ProductDrive") },
8686
class_name: "Tag", inverse_of: false
8787
has_many :inventory_items, through: :storage_locations
88+
has_many :concrete_items
8889
has_many :kit_items
8990
has_many :transfers
9091
has_many :users, -> { distinct }, through: :roles

spec/models/item_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
kit_params[:line_items_attributes] = [{item_id: item.id, quantity: 1}]
7373
KitCreateService.new(organization_id: organization.id, kit_params: kit_params).call # shouldn't be counted
7474

75-
expect(ConcreteItem.where(organization: organization).count).to eq(1)
76-
expect(ConcreteItem.where(organization: organization).first.name).to eq(name)
75+
expect(organization.concrete_items.count).to eq(1)
76+
expect(organization.concrete_items.first.name).to eq(name)
7777
end
7878

7979
specify "->alphabetized retrieves items in alphabetical order" do

0 commit comments

Comments
 (0)