Skip to content

Commit 92aae5b

Browse files
committed
Promotions: Remove optional from belongs_to declarations
All of these have foreign key constraints set and are actually necessary for the respective records to function.
1 parent cf8ff04 commit 92aae5b

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

promotions/app/models/solidus_promotions/condition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module SolidusPromotions
66
class Condition < Spree::Base
77
include Spree::Preferences::Persistable
88

9-
belongs_to :benefit, class_name: "SolidusPromotions::Benefit", inverse_of: :conditions, optional: true
9+
belongs_to :benefit, class_name: "SolidusPromotions::Benefit", inverse_of: :conditions
1010
has_one :promotion, through: :benefit
1111

1212
scope :of_type, ->(type) { where(type: type) }

promotions/app/models/solidus_promotions/condition_product.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module SolidusPromotions
44
class ConditionProduct < Spree::Base
5-
belongs_to :condition, class_name: "SolidusPromotions::Condition", optional: true
6-
belongs_to :product, class_name: "Spree::Product", optional: true
5+
belongs_to :condition, class_name: "SolidusPromotions::Condition"
6+
belongs_to :product, class_name: "Spree::Product"
77
end
88
end

promotions/app/models/solidus_promotions/condition_store.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module SolidusPromotions
44
class ConditionStore < Spree::Base
5-
belongs_to :condition, class_name: "SolidusPromotions::Condition", optional: true
6-
belongs_to :store, class_name: "Spree::Store", optional: true
5+
belongs_to :condition, class_name: "SolidusPromotions::Condition"
6+
belongs_to :store, class_name: "Spree::Store"
77
end
88
end

promotions/app/models/solidus_promotions/condition_taxon.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module SolidusPromotions
44
class ConditionTaxon < Spree::Base
5-
belongs_to :condition, class_name: "SolidusPromotions::Condition", optional: true
6-
belongs_to :taxon, class_name: "Spree::Taxon", optional: true
5+
belongs_to :condition, class_name: "SolidusPromotions::Condition"
6+
belongs_to :taxon, class_name: "Spree::Taxon"
77
end
88
end

promotions/app/models/solidus_promotions/condition_user.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module SolidusPromotions
44
class ConditionUser < Spree::Base
5-
belongs_to :condition, class_name: "SolidusPromotions::Condition", optional: true
6-
belongs_to :user, class_name: Spree::UserClassHandle.new, optional: true
5+
belongs_to :condition, class_name: "SolidusPromotions::Condition"
6+
belongs_to :user, class_name: Spree::UserClassHandle.new
77
end
88
end

promotions/spec/models/solidus_promotions/condition_product.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require "rails_helper"
44

55
RSpec.describe SolidusPromotions::ConditionProduct do
6-
it { is_expected.to belong_to(:product).optional }
7-
it { is_expected.to belong_to(:condition).optional }
6+
it { is_expected.to belong_to(:product) }
7+
it { is_expected.to belong_to(:condition) }
88
end

promotions/spec/models/solidus_promotions/condition_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "rails_helper"
44

55
RSpec.describe SolidusPromotions::Condition do
6-
it { is_expected.to belong_to(:benefit).optional }
6+
it { is_expected.to belong_to(:benefit) }
77
let(:bad_test_condition_class) { Class.new(SolidusPromotions::Condition) }
88
let(:test_condition_class) do
99
Class.new(SolidusPromotions::Condition) do

promotions/spec/models/solidus_promotions/condition_store_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require "rails_helper"
44

55
RSpec.describe SolidusPromotions::ConditionStore do
6-
it { is_expected.to belong_to(:store).optional }
7-
it { is_expected.to belong_to(:condition).optional }
6+
it { is_expected.to belong_to(:store) }
7+
it { is_expected.to belong_to(:condition) }
88
end

promotions/spec/models/solidus_promotions/condition_taxon_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require "rails_helper"
44

55
RSpec.describe SolidusPromotions::ConditionTaxon do
6-
it { is_expected.to belong_to(:taxon).optional }
7-
it { is_expected.to belong_to(:condition).optional }
6+
it { is_expected.to belong_to(:taxon) }
7+
it { is_expected.to belong_to(:condition) }
88
end

promotions/spec/models/solidus_promotions/condition_user_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require "rails_helper"
44

55
RSpec.describe SolidusPromotions::ConditionUser do
6-
it { is_expected.to belong_to(:user).optional }
7-
it { is_expected.to belong_to(:condition).optional }
6+
it { is_expected.to belong_to(:user) }
7+
it { is_expected.to belong_to(:condition) }
88
end

0 commit comments

Comments
 (0)