Skip to content

Commit

Permalink
Add has_many folded_pages association to Spree::User
Browse files Browse the repository at this point in the history
Rails 6 checks on the reverse association being present.
  • Loading branch information
tvdeyen committed Aug 5, 2020
1 parent b399340 commit a8ca18e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
log/*.log
pkg/
/spec/dummy/
!/spec/dummy/app/models/spree/user.rb
Gemfile.lock
.ruby-version
4 changes: 4 additions & 0 deletions lib/alchemy/solidus/spree_user_extension.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module Alchemy
module Solidus
module SpreeUserExtension
def self.included(klass)
klass.has_many :folded_pages, class_name: "Alchemy::FoldedPage"
end

def alchemy_roles
if has_spree_role?(:admin)
%w(admin)
Expand Down
7 changes: 7 additions & 0 deletions spec/dummy/app/models/spree/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require "alchemy/solidus/spree_user_extension"

class Spree::User < ActiveRecord::Base
include Alchemy::Solidus::SpreeUserExtension
end
7 changes: 7 additions & 0 deletions spec/models/spree/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe Spree::User do
it { is_expected.to have_many(:folded_pages).class_name("Alchemy::FoldedPage") }
end

0 comments on commit a8ca18e

Please sign in to comment.