Skip to content

Commit

Permalink
Merge pull request solidusio#3772 from tvdeyen/fix-event_links-transl…
Browse files Browse the repository at this point in the history
…ations

Make admin order event_links translatable
  • Loading branch information
kennyadsl authored Sep 30, 2020
2 parents d7fa395 + 0ce33ec commit f084fb1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/app/helpers/spree/admin/orders_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ def event_links
links = []
@order_events.sort.each do |event|
next unless @order.send("can_#{event}?")
links << button_to(t(event, scope: 'spree'), [event, :admin, @order],
method: :put,
data: { confirm: t('spree.order_sure_want_to', event: t(event, scope: 'spree')) })
translated_event = t(event, scope: [:spree, :admin, :order, :events])
links << button_to(
translated_event,
[event, :admin, @order],
method: :put,
data: { confirm: t(:order_sure_want_to, event: translated_event, scope: :spree) }
)
end
safe_join(links, '&nbsp;'.html_safe)
safe_join(links, "&nbsp;".html_safe)
end

def line_item_shipment_price(line_item, quantity)
Expand Down
53 changes: 53 additions & 0 deletions backend/spec/helpers/admin/orders_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

require "spec_helper"

describe Spree::Admin::OrdersHelper, type: :helper do
describe "#event_links" do
subject { helper.event_links }

before do
helper.class.include Spree::Admin::NavigationHelper
helper.class.include Spree::Core::Engine.routes.url_helpers
@order_events = %w{approve cancel resume}
end

context "with an uncompleted order" do
before do
@order = create(:order)
end

it "renders link to approve order" do
is_expected.to have_button("Approve")
end
end

context "with a complete order" do
before do
@order = create(:completed_order_with_totals)
end

it "renders link to approve order" do
is_expected.to have_button("Approve")
end

it "renders link to cancel order" do
is_expected.to have_button("Cancel")
end
end

context "with a canceled order" do
before do
@order = create(:completed_order_with_totals).tap(&:cancel!)
end

it "renders link to approve order" do
is_expected.to have_button("Approve")
end

it "renders link to resume order" do
is_expected.to have_button("Resume")
end
end
end
end
5 changes: 5 additions & 0 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@ en:
drag_and_drop: or drag and drop them here
image_process_failed: Server failed to process the image
upload_images: Upload Images
order:
events:
approve: Approve
cancel: Cancel
resume: Resume
payments:
source_forms:
storecredit:
Expand Down

0 comments on commit f084fb1

Please sign in to comment.