Skip to content

Commit

Permalink
Merge pull request #1669 from tvdeyen/test-support-fixes
Browse files Browse the repository at this point in the history
Test support fixes
  • Loading branch information
tvdeyen authored Nov 7, 2019
2 parents 93dd8c0 + 103d75f commit 3e43e4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/models/alchemy/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# locale :string
#

require_dependency 'alchemy/site'

module Alchemy
class Language < BaseRecord
belongs_to :site
Expand Down
19 changes: 12 additions & 7 deletions lib/alchemy/test_support/essence_shared_examples.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
require 'rails_helper'
# frozen_string_literal: true

shared_examples_for "an essence" do
require 'shoulda-matchers'
require 'alchemy/test_support/factories/page_factory'
require 'alchemy/test_support/factories/element_factory'
require 'alchemy/test_support/factories/content_factory'

RSpec.shared_examples_for "an essence" do
let(:element) { Alchemy::Element.new }
let(:content) { Alchemy::Content.new(name: 'foo') }
let(:content_definition) { {'name' => 'foo'} }

it "touches the content after update" do
element = create(:alchemy_element)
content = create(:alchemy_content, element: element, essence: essence, essence_type: essence.class.name)
element = FactoryBot.create(:alchemy_element)
content = FactoryBot.create(:alchemy_content, element: element, essence: essence, essence_type: essence.class.name)

content.update_column(:updated_at, 3.days.ago)
content.essence.update(essence.ingredient_column.to_sym => ingredient_value)
Expand Down Expand Up @@ -153,7 +158,7 @@

describe 'uniqueness' do
before do
allow(essence).to receive(:element).and_return(build_stubbed(:alchemy_element))
allow(essence).to receive(:element).and_return(FactoryBot.build_stubbed(:alchemy_element))
essence.update(essence.ingredient_column.to_sym => ingredient_value)
end

Expand Down Expand Up @@ -256,8 +261,8 @@
end

describe 'essence relations' do
let(:page) { create(:alchemy_page, :restricted) }
let(:element) { create(:alchemy_element) }
let(:page) { FactoryBot.create(:alchemy_page, :restricted) }
let(:element) { FactoryBot.create(:alchemy_element) }

it "registers itself on page as essence relation" do
expect(page.respond_to?(essence.class.model_name.route_key)).to be(true)
Expand Down

0 comments on commit 3e43e4b

Please sign in to comment.