Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and add specs to stock locations helper #3827

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions backend/app/helpers/spree/admin/stock_locations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ module Spree
module Admin
module StockLocationsHelper
def admin_stock_location_display_name(stock_location)
name_parts = [stock_location.admin_name, stock_location.name]
name_parts.delete_if(&:blank?)
name_parts.join(' / ')
[stock_location.admin_name, stock_location.name].reject(&:blank?).join(' / ')
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions backend/spec/helpers/admin/stock_locations_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'spec_helper'

describe Spree::Admin::StockLocationsHelper, type: :helper do
describe "#admin_stock_location_display_name" do
subject { helper.admin_stock_location_display_name(stock_location) }

context "without admin_name" do
let(:stock_location) { create(:stock_location_with_items, name: "NY Warehouse") }

it { is_expected.to eq "NY Warehouse" }
end

context "with admin_name" do
let(:stock_location) { create(:stock_location_with_items, name: "NY Warehouse", admin_name: "solidus") }

it { is_expected.to eq "solidus / NY Warehouse" }
end
end
end