This file contains hidden or 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 hidden or 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 |
This file contains hidden or 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_relative "../../../app/services/groupments/group_shipments" | |
FakeShipment = Struct.new(:parcel, :courier, :shipment_items) do | |
def courier? | |
courier | |
end | |
def parcel? |
This file contains hidden or 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
module Casper | |
module OrderPublishing | |
def publish_to_queue(routing_key) | |
::Hutch::Casper::Publisher.publish(routing_key, serialized_order, {type: 'order'}) | |
end | |
def publish_tax_breakdown(routing_key) | |
::Hutch::Casper::Publisher.publish(routing_key, TaxBreakdownSerializer.new(self).as_json) | |
end |
This file contains hidden or 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" | |
module PI | |
extend self | |
def call(str) | |
return mask_email(str) if str =~ /@/ | |
mask_phone(str) | |
end |
This file contains hidden or 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 WarehouseAssignment | |
module Rates | |
class UpdateWithCheapest | |
def self.call(options:) | |
new(options: Array(options)).to_a | |
end | |
def initialize(options:) |
This file contains hidden or 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
module Scans | |
class Action | |
def self.call(scan) | |
factory(scan).call | |
end | |
def self.factory(scan) | |
const_get(scan.type.camelcase).new(scan) | |
end |
This file contains hidden or 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 "rails_helper" | |
feature "Users search shipment", :as_admin_user do | |
context 'with sorting' do | |
scenario 'takes the user-defined sorting' do | |
shipment1 = create :shipment, number: 'Shipment 1', order_completed_at: 2.days.ago | |
shipment2 = create :shipment, number: 'Shipment 2', vip: true | |
shipment3 = create :shipment, number: 'Shipment 3', status: 'canceled' | |
visit shipments_path |
This file contains hidden or 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 "rails_helper" | |
describe WarehouseShowPresenter do | |
subject(:presenter) { described_class.new(warehouse) } | |
let(:warehouse) { create(:warehouse) } | |
let(:product) do | |
create(:product, id: 1, | |
variation_count: 2, | |
category: 1, |