-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6004 from solidusio/backport/v4.4/pr-5999
[v4.4] Do not constantize Spree.user_class in UserClassHandle
- Loading branch information
Showing
3 changed files
with
43 additions
and
2 deletions.
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
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,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
require "spree/core" | ||
require "spree/user_class_handle" | ||
|
||
RSpec.describe Spree::UserClassHandle do | ||
describe "#to_s" do | ||
around do |example| | ||
@prev_user_class = Spree.user_class_name | ||
example.run | ||
Spree.user_class = @prev_user_class | ||
end | ||
|
||
subject { described_class.new.to_s } | ||
|
||
context "when Spree.user_class is nil" do | ||
before do | ||
Spree.user_class = nil | ||
end | ||
|
||
it "is expected to fail" do | ||
expect { subject }.to raise_error(RuntimeError, "'Spree.user_class' has not been set yet.") | ||
end | ||
end | ||
|
||
context "when Spree.user_class is not nil" do | ||
before do | ||
Spree.user_class = "Spree::User" | ||
end | ||
|
||
it "is expected to return the user class as a string" do | ||
expect(subject).to eq("::Spree::User") | ||
end | ||
end | ||
end | ||
end |