Explicitely touch instead of noop save

When calling `save!` without changing any attributes then Rails doesn't
always touch other records because nothing changed. So I changed the
spec to `touch` explicitely and it turns out that everything passes.

Tada, our code seems correct and it was only the spec which seemed
broken in Rails 7.
This commit is contained in:
Maikel Linke
2023-03-03 12:43:01 +11:00
parent 103bc50bdc
commit 12906d1e13

View File

@@ -20,21 +20,21 @@ describe Enterprise do
enterprise.set_producer_property 'Biodynamic', 'ASDF 4321'
end
pending "touches enterprise when a classification on that product changes" do
it "touches enterprise when a classification on that product changes" do
expect {
later { classification.save! }
later { classification.touch }
}.to change { enterprise.reload.updated_at }
end
pending "touches enterprise when a property on that product changes" do
it "touches enterprise when a property on that product changes" do
expect {
later { property.save! }
later { property.touch }
}.to change { enterprise.reload.updated_at }
end
pending "touches enterprise when a producer property on that product changes" do
it "touches enterprise when a producer property on that product changes" do
expect {
later { producer_property.save! }
later { producer_property.touch }
}.to change { enterprise.reload.updated_at }
end
@@ -64,21 +64,21 @@ describe Enterprise do
context "with an order cycle" do
before { oc }
pending "touches enterprise when a classification on that product changes" do
it "touches enterprise when a classification on that product changes" do
expect {
later { classification.save! }
later { classification.touch }
}.to change { enterprise.reload.updated_at }
end
pending "touches enterprise when a property on that product changes" do
it "touches enterprise when a property on that product changes" do
expect {
later { property.save! }
later { property.touch }
}.to change { enterprise.reload.updated_at }
end
pending "touches enterprise when a producer property on that product changes" do
it "touches enterprise when a producer property on that product changes" do
expect {
later { producer_property.save! }
later { producer_property.touch }
}.to change { enterprise.reload.updated_at }
end
@@ -106,9 +106,9 @@ describe Enterprise do
let(:child_enterprise) { create(:supplier_enterprise) }
let!(:er) { create(:enterprise_relationship, parent: enterprise, child: child_enterprise) }
pending "touches enterprise when enterprise relationship is updated" do
it "touches enterprise when enterprise relationship is updated" do
expect {
later { er.save! }
later { er.touch }
}.to change { enterprise.reload.updated_at }
end
end
@@ -120,9 +120,9 @@ describe Enterprise do
enterprise.shipping_methods << sm
end
pending "touches enterprise when distributor_shipping_method is updated" do
it "touches enterprise when distributor_shipping_method is updated" do
expect {
later { enterprise.distributor_shipping_methods.first.save! }
later { enterprise.distributor_shipping_methods.first.touch }
}.to change { enterprise.reload.updated_at }
end