-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
870 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,5 @@ yarn-debug.log* | |
.ionide | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode | ||
|
||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class Role < ApplicationRecord | ||
has_many :users, inverse_of: :role, dependent: :restrict_with_exception | ||
|
||
validates :name, | ||
presence: true, | ||
uniqueness: { | ||
case_sensitive: false | ||
}, | ||
length: { | ||
minimum: 2, | ||
maximum: 40 | ||
in: 2..40 | ||
}, | ||
format: /\A([^\d\W]|-|\s)*\z/ | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class Stock < ApplicationRecord | ||
belongs_to :product | ||
belongs_to :product, inverse_of: :stocks | ||
|
||
has_many :order_items, inverse_of: :stock, dependent: :restrict_with_exception | ||
|
||
broadcasts_refreshes_to :product | ||
broadcasts_refreshes | ||
|
||
validates :size, presence: true, uniqueness: { scope: :product_id, case_sensitive: false } | ||
validates :quantity, | ||
presence: true, | ||
numericality: { | ||
greater_than_or_equal_to: 0, | ||
less_than_or_equal_to: 999_999_999 | ||
} | ||
validates :quantity, presence: true, numericality: { only_integer: true, in: 0..999_999_999 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :category do | ||
sequence(:name) { |n| "Category #{n}" } | ||
description { "Description" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :order_item do | ||
order | ||
product | ||
stock { association(:stock, product:) } | ||
order_code { order.order_code } | ||
product_name { product.name } | ||
product_price { product.price } | ||
size { stock.size } | ||
quantity { 2 } | ||
end | ||
end |
Oops, something went wrong.