diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..30cf57e
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..a11a7f6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/price-point-api.iml b/.idea/price-point-api.iml
new file mode 100644
index 0000000..7546ea2
--- /dev/null
+++ b/.idea/price-point-api.iml
@@ -0,0 +1,251 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$MODULE_DIR$/app
+
+
+ file://$MODULE_DIR$/app/assets
+
+
+ file://$MODULE_DIR$/app/channels
+
+
+ file://$MODULE_DIR$/app/controllers
+
+
+ file://$MODULE_DIR$/app/helpers
+
+
+ file://$MODULE_DIR$/app/mailers
+
+
+ file://$MODULE_DIR$/app/models
+
+
+ file://$MODULE_DIR$/app/views
+
+
+ file://$MODULE_DIR$/config
+
+
+ file://$MODULE_DIR$/config/cable.yml
+
+
+ file://$MODULE_DIR$/config/cache.yml
+
+
+ file://$MODULE_DIR$/config/database.yml
+
+
+ file://$MODULE_DIR$/config/environment.rb
+
+
+ file://$MODULE_DIR$/config/environments
+
+
+ file://$MODULE_DIR$/config/initializers
+
+
+ file://$MODULE_DIR$/config/locales
+
+
+ file://$MODULE_DIR$/config/routes
+
+
+ file://$MODULE_DIR$/config/routes.rb
+
+
+ file://$MODULE_DIR$/config/solid_cache.yml
+
+
+ file://$MODULE_DIR$/db
+
+
+ file://$MODULE_DIR$/db/migrate
+
+
+ file://$MODULE_DIR$/db/seeds.rb
+
+
+ file://$MODULE_DIR$/lib
+
+
+ file://$MODULE_DIR$/lib/assets
+
+
+ file://$MODULE_DIR$/lib/tasks
+
+
+ file://$MODULE_DIR$/lib/templates
+
+
+ file://$MODULE_DIR$/log/development.log
+
+
+ file://$MODULE_DIR$/public
+
+
+ file://$MODULE_DIR$/public/javascripts
+
+
+ file://$MODULE_DIR$/public/stylesheets
+
+
+ file://$MODULE_DIR$/test/mailers/previews
+ file://$MODULE_DIR$/test/mailers/previews
+
+
+ file://$MODULE_DIR$/tmp
+
+
+ file://$MODULE_DIR$/vendor
+
+
+ file://$MODULE_DIR$/vendor/assets
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/models/admin.rb b/app/models/admin.rb
index 74bbeff..0d797bd 100644
--- a/app/models/admin.rb
+++ b/app/models/admin.rb
@@ -14,4 +14,5 @@
# index_admins_on_email (email) UNIQUE
#
class Admin < ApplicationRecord
+ has_many :moderation_logs, dependent: :destroy
end
diff --git a/app/models/chain.rb b/app/models/chain.rb
index 7f5ba9b..b1f00a3 100644
--- a/app/models/chain.rb
+++ b/app/models/chain.rb
@@ -9,4 +9,5 @@
#
class Chain < ApplicationRecord
has_one_attached :image
+ has_many :stores, dependent: :destroy
end
diff --git a/app/models/guest.rb b/app/models/guest.rb
index 5294465..760dbd0 100644
--- a/app/models/guest.rb
+++ b/app/models/guest.rb
@@ -9,4 +9,6 @@
# updated_at :datetime not null
#
class Guest < ApplicationRecord
+ has_many :price_reports, dependent: :destroy
+ has_many :moderation_logs, as: :moderatable, dependent: :destroy
end
diff --git a/app/models/price_report.rb b/app/models/price_report.rb
index 2e588e4..9d9942e 100644
--- a/app/models/price_report.rb
+++ b/app/models/price_report.rb
@@ -30,4 +30,5 @@ class PriceReport < ApplicationRecord
belongs_to :product
belongs_to :store
belongs_to :guest
+ has_many :moderation_logs, as: :moderatable, dependent: :destroy
end
diff --git a/app/models/product.rb b/app/models/product.rb
index 2e4df25..ac4c83d 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -14,4 +14,5 @@
#
class Product < ApplicationRecord
has_one_attached :image
+ has_many :price_reports, dependent: :destroy
end
diff --git a/app/models/store.rb b/app/models/store.rb
index 2277aa3..e4840f0 100644
--- a/app/models/store.rb
+++ b/app/models/store.rb
@@ -21,4 +21,5 @@
class Store < ApplicationRecord
has_one_attached :image
belongs_to :chain
+ has_many :price_reports, dependent: :destroy
end
diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb
index 518cdfb..a9aed20 100644
--- a/test/controllers/products_controller_test.rb
+++ b/test/controllers/products_controller_test.rb
@@ -12,7 +12,7 @@ class ProductsControllerTest < ActionDispatch::IntegrationTest
test "should create product" do
assert_difference("Product.count") do
- post products_url, params: { product: { barcode: @product.barcode, name: @product.name } }, as: :json
+ post products_url, params: { product: { barcode: "unique_barcode_123", name: @product.name } }, as: :json
end
assert_response :created
diff --git a/test/fixtures/admins.yml b/test/fixtures/admins.yml
index 03a1b0a..eb79181 100644
--- a/test/fixtures/admins.yml
+++ b/test/fixtures/admins.yml
@@ -16,11 +16,11 @@
# index_admins_on_email (email) UNIQUE
#
one:
- name: MyString
- email: MyString
+ name: Admin
+ email: admin@test.com
password_digest: MyString
two:
- name: MyString
- email: MyString
+ name: Mod
+ email: mod@test.com
password_digest: MyString
diff --git a/test/fixtures/moderation_logs.yml b/test/fixtures/moderation_logs.yml
index bf22b9d..38f2fba 100644
--- a/test/fixtures/moderation_logs.yml
+++ b/test/fixtures/moderation_logs.yml
@@ -23,12 +23,10 @@
#
one:
reason: MyString
- moderatable: one
- moderatable_type: Moderatable
+ moderatable: one (Chain)
admin: one
two:
reason: MyString
- moderatable: two
- moderatable_type: Moderatable
+ moderatable: two (Chain)
admin: two
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
index a59ba7e..aa90e94 100644
--- a/test/fixtures/products.yml
+++ b/test/fixtures/products.yml
@@ -17,3 +17,7 @@
one:
name: MyString
barcode: MyString
+
+two:
+ name: MyString2
+ barcode: MyString2