Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix creating gift card batches (#13202)
Łukasz Adamczykf43a5b9d54c1
diff --git a/admin/app/views/spree/admin/gift_card_batches/new.html.erb b/admin/app/views/spree/admin/gift_card_batches/new.html.erbindex 0fd3668cab..5a6dcd6262 100644--- a/admin/app/views/spree/admin/gift_card_batches/new.html.erb+++ b/admin/app/views/spree/admin/gift_card_batches/new.html.erb@@ -1 +1 @@-<%= render 'spree/admin/shared/new_resource' %>\ No newline at end of file+<%= render 'spree/admin/shared/new_resource', form_url: spree.admin_gift_card_batches_path %>diff --git a/admin/app/views/spree/admin/shared/_new_resource.html.erb b/admin/app/views/spree/admin/shared/_new_resource.html.erbindex 788593ac70..7e26c66163 100644--- a/admin/app/views/spree/admin/shared/_new_resource.html.erb+++ b/admin/app/views/spree/admin/shared/_new_resource.html.erb@@ -1,12 +1,13 @@<% col_class ||= 'col-lg-6 offset-lg-3' %><% page_header_back_button_url ||= collection_url %>+<% form_url ||= collection_url %><%= content_for :page_title do %><%= page_header_back_button(page_header_back_button_url) %><%= Spree.t("new_#{controller_name.singularize}") %><% end %>-<%= form_with model: [:admin, @object], url: collection_url, id: "new_#{controller_name.singularize}", data: local_assigns[:data] || {} do |f| %>+<%= form_with model: [:admin, @object], url: form_url, id: "new_#{controller_name.singularize}", data: local_assigns[:data] || {} do |f| %><div class="row"><div class="<%= col_class %>"><%= render 'spree/admin/shared/error_messages', target: @object %>diff --git a/admin/spec/features/spree/admin/gift_card_batches_spec.rb b/admin/spec/features/spree/admin/gift_card_batches_spec.rbnew file mode 100644index 0000000000..c641a5cd8e--- /dev/null+++ b/admin/spec/features/spree/admin/gift_card_batches_spec.rb@@ -0,0 +1,30 @@+require 'spec_helper'++RSpec.describe 'Gift Card Batches', type: :feature do+ stub_authorization!++ let(:store) { @default_store }+ let(:store_gift_card_batches) { Spree::GiftCardBatch.for_store(store) }++ scenario 'admin creates a new gift card batch' do+ visit spree.new_admin_gift_card_batch_path++ fill_in 'Prefix', with: 'TEST-GC'+ fill_in 'Amount', with: 5+ fill_in 'Codes count', with: 5++ click_on 'Create'++ expect(page).to have_content('Gift card batch has been successfully created!')+ expect(page).to have_current_path(spree.admin_gift_cards_path(q: { batch_prefix_eq: 'TEST-GC' }))++ expect(store_gift_card_batches.count).to eq(1)+ expect(store_gift_card_batches.first.prefix).to eq('TEST-GC')+ expect(store_gift_card_batches.first.amount).to eq(5)+ expect(store_gift_card_batches.first.codes_count).to eq(5)++ store_gift_card_batches.first.gift_cards.each do |gift_card|+ expect(page).to have_content(gift_card.code.upcase)+ end+ end+end