-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12755 from johansenja/optimise-shops-page6
Optimise shops page: Enable injected enterprise data to be scoped to specific enterprise ids
- Loading branch information
Showing
9 changed files
with
278 additions
and
97 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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'open_food_network/enterprise_injection_data' | ||
|
||
RSpec.describe OpenFoodNetwork::EnterpriseInjectionData do | ||
let(:enterprise1) { create :distributor_enterprise, with_payment_and_shipping: true } | ||
let(:enterprise2) { create :distributor_enterprise, with_payment_and_shipping: true } | ||
let(:enterprise3) { create :distributor_enterprise, with_payment_and_shipping: true } | ||
let(:enterprise4) { create :distributor_enterprise, with_payment_and_shipping: true } | ||
|
||
before do | ||
[enterprise1, enterprise2, enterprise3].each do |ent| | ||
create :open_order_cycle, distributors: [ent] | ||
end | ||
end | ||
|
||
let!(:closed_oc) { create :closed_order_cycle, coordinator: enterprise4 } | ||
|
||
context "when scoped to specific enterprises" do | ||
subject { | ||
described_class.new([enterprise1.id, enterprise2.id]) | ||
} | ||
|
||
describe "#active_distributor_ids" do | ||
it "should include enterprise1.id and enterprise2.id" do | ||
ids = subject.active_distributor_ids | ||
expect(ids).to include enterprise1.id | ||
expect(ids).to include enterprise2.id | ||
expect(ids).not_to include enterprise3.id | ||
end | ||
end | ||
end | ||
|
||
context "when unscoped to specific enterprises" do | ||
let(:subject) { described_class.new } | ||
|
||
describe "#active_distributor_ids" do | ||
it "should include all enterprise ids" do | ||
ids = subject.active_distributor_ids | ||
expect(ids).to include enterprise1.id | ||
expect(ids).to include enterprise2.id | ||
expect(ids).to include enterprise3.id | ||
end | ||
end | ||
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
Oops, something went wrong.