-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
[Bye bye spree] Bring base_helper and log_entry from spree core #5924
Merged
luisramos0
merged 5 commits into
openfoodfoundation:master
from
luisramos0:basic_spree_core
Sep 16, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7ec00cf
Bring base files from spree_core
luisramos0 c151195
Merge decorator with original class and delete dead code
luisramos0 2f93a06
Run rubocop -a on files brought from spree_core
luisramos0 b413f85
Clarify that it's a Spree issue number
luisramos0 865a4b3
Fix base helper spec
luisramos0 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
class LogEntry < ActiveRecord::Base | ||
belongs_to :source, polymorphic: true | ||
|
||
# Fix for Spree #1767 | ||
# If a payment fails, we want to make sure we keep the record of it failing | ||
after_rollback :save_anyway | ||
|
||
def save_anyway | ||
log = Spree::LogEntry.new | ||
log.source = source | ||
log.details = details | ||
log.save! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Spree::BaseHelper do | ||
include Spree::BaseHelper | ||
|
||
context "available_countries" do | ||
let(:country) { create(:country) } | ||
|
||
before do | ||
3.times { create(:country) } | ||
end | ||
|
||
context "with no checkout zone defined" do | ||
before do | ||
Spree::Config[:checkout_zone] = nil | ||
end | ||
|
||
it "return complete list of countries" do | ||
expect(available_countries.count).to eq Spree::Country.count | ||
end | ||
end | ||
|
||
context "with a checkout zone defined" do | ||
context "checkout zone is of type country" do | ||
before do | ||
@country_zone = create(:zone, name: "CountryZone") | ||
@country_zone.members.create(zoneable: country) | ||
Spree::Config[:checkout_zone] = @country_zone.name | ||
end | ||
|
||
it "return only the countries defined by the checkout zone" do | ||
expect(available_countries).to eq [country] | ||
end | ||
end | ||
|
||
context "checkout zone is of type state" do | ||
before do | ||
state_zone = create(:zone, name: "StateZone") | ||
state = create(:state, country: country) | ||
state_zone.members.create(zoneable: state) | ||
Spree::Config[:checkout_zone] = state_zone.name | ||
end | ||
|
||
it "return complete list of countries" do | ||
expect(available_countries.count).to eq Spree::Country.count | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "pretty_time" do | ||
it "prints in a format" do | ||
expect(pretty_time(DateTime.new(2012, 5, 6, 13, 33))).to eq "May 06, 2012 1:33 PM" | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking out loud: It would've been much easier not to include this in the same DB transaction so it wouldn't have been rolled back.