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
context "when there are shipments that have bundleable products" do | |
let(:shipments_in) { [shipment1, shipment2] } | |
let(:shipment1) { build(:shipment, products: [product_a]) } | |
let(:shipment2) { build(:shipment, products: [product_b]) } | |
it "returns the bundling product instead of the bundleable ones" do | |
expect(shipments_out.first.products).to match_array(product_c) | |
end | |
it "does not return the unused shipment" do |
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
[41] pry(main)> person | |
=> {:pounds=>135, :kcal=>1500} | |
[42] pry(main)> macros | |
=> [{:protein_per_pound=>0.36, :fat_per_pound=>0.5, :daily_carbs=>255}] | |
[43] pry(main)> oatmeal_macros | |
=> {:cup=>{:protein=>5.9, :fat=>3.6, :carbs=>28.1}} | |
[44] pry(main)> raisins_macros | |
=> {:cup=>{:protein=>0.0, :fat=>0.0, :carbs=>33}} | |
[45] pry(main)> person = macros.reduce(person) do |person, macro| | |
[45] pry(main)* person = person.merge({protein_needed: person[:pounds] * macro[:protein_per_pound]}) |
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
package main | |
import ( | |
"os" | |
"fmt" | |
"gitlab.com/george.rafael/restaurant-gr/internal/restaurant" | |
"gitlab.com/george.rafael/restaurant-gr/internal/stats" | |
) |
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
# frozen_string_literal: true | |
module Shipments | |
class Build | |
def self.shipments_for(shipments_payload:) | |
shipments_payload.map do |shipment_payload| | |
call(payload: shipment_payload) | |
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
# frozen_string_literal: true | |
require "rails_helper" | |
RSpec.describe Groupments::OrderSerializer do | |
subject(:payload) do | |
described_class.new( | |
grouped_shipments: shipments, | |
unused_shipment_numbers: unused_shipment_numbers, | |
order_number: order_number |
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
# frozen_string_literal: true | |
require "timecop" | |
require "active_support/all" | |
require_relative "../../../../app/services/flexe/notification_handlers/retail_fulfillment_order_info" | |
describe Flexe::NotificationHandlers::RetailFulfillmentOrderInfo do | |
subject(:retail_fulfillment_order_info) do | |
described_class.for(attrs) | |
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
# frozen_string_literal: true | |
require "timecop" | |
require "active_support/all" | |
require_relative "../../../../app/services/flexe/notification_handlers/retail_fulfillment_order_info" | |
describe Flexe::NotificationHandlers::RetailFulfillmentOrderInfo do | |
subject(:retail_fulfillment_order_info) do | |
described_class.for(attrs) | |
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
# frozen_string_literal: true | |
require "rails_helper" | |
describe Bedpost::Orders::ReadyToGroup, type: :consumer do | |
subject(:process_ready_to_group) { described_class.new.process(payload) } | |
let(:shipments_message) do | |
{ | |
shipments: fixtures_for_shipments(shipments), |
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
require "minitest/autorun" | |
require "minitest/pride" | |
module ParenthesisValidator | |
extend self | |
OPENERS = %w|( { [| | |
def call(code) | |
return false if code.size == 1 | |
openers = [] |
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
# frozen_string_literal: true | |
module Groupments | |
class GroupShipments | |
def self.call(shipments:) | |
new(shipments: shipments).call.grouped_shipments | |
end | |
attr_reader :grouped_shipments |