Skip to content

Commit

Permalink
refact and add specs to stock locations helper
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbaldao committed Nov 5, 2020
1 parent 0e35bb6 commit 6f35c73
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
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].compact.join(' / ')
end
end
end
Expand Down
22 changes: 22 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,22 @@
# 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) }

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

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

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

0 comments on commit 6f35c73

Please sign in to comment.