Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Add a partial for the hash preference field
Browse files Browse the repository at this point in the history
We store two settings inside a hash preference field. Solidus 2.4
is missing this partial. As will hopefully be fixed with Solidus 2.5
we load our own partial if we are using Solidus 2.4
  • Loading branch information
tvdeyen committed Nov 21, 2017
1 parent d97ba70 commit a931050
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/solidus_paypal_braintree/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def self.activate
# source form partial. This will take precedence over lib/views/backend.
paths["app/views"] << "lib/views/backend_v1.2" if SolidusSupport.solidus_gem_version < Gem::Version.new('1.3')

# Solidus v2.4 introduced preference field partials but does not ship a hash field type.
# This is solved in Solidus v2.5.
if SolidusSupport.solidus_gem_version <= Gem::Version.new('2.5.0')
paths["app/views"] << "lib/views/backend_v2.4"
end

paths["app/views"] << "lib/views/backend"
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% label = local_assigns[:label].presence %>
<% html_options = {class: 'input_hash fullwidth'}.update(local_assigns[:html_options] || {}) %>

<div class="field">
<% if local_assigns[:form] %>
<%= form.label attribute, label %>
<%= form.text_area attribute, html_options %>
<% else %>
<%= label_tag name, label %>
<%= text_area_tag name, value, html_options %>
<% end %>
</div>
14 changes: 13 additions & 1 deletion spec/features/backend/configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
require 'spec_helper'

RSpec.describe "viewing the configuration interface", js: true do
RSpec.describe "viewing the configuration interface" do
stub_authorization!

# Regression to ensure this page still renders on old versions of solidus
scenario "should not raise any errors due to unavailable route helpers" do
visit "/solidus_paypal_braintree/configurations/list"
expect(page).to have_content("Braintree Configurations")
end

# Regression to ensure this page renders on Solidus 2.4
scenario 'should not raise any errors due to unavailable preference field partial' do
Rails.application.config.spree.payment_methods << SolidusPaypalBraintree::Gateway
Spree::PaymentMethod.create!(
type: 'SolidusPaypalBraintree::Gateway',
name: 'Braintree Payments'
)
visit '/admin/payment_methods'
page.find('a[title="Edit"]').click
expect(page).to have_field 'Name', with: 'Braintree Payments'
end
end

0 comments on commit a931050

Please sign in to comment.