Sha256: 9eb6ae841f5249a70539f19787ebc9be73e3768292eef72f53881d3fd1fa865e

Contents?: true

Size: 1.45 KB

Versions: 31

Compression:

Stored size: 1.45 KB

Contents

require 'rails_helper'

describe Pulitzer::UpdatePostTypeContentElements do
  let(:version)     { post.preview_version }
  let(:post_type_version) {post_type.published_type_version}
  let(:post)        { post_type_version.posts.first }
  let(:post_type)   { Pulitzer::PostType.named('Welcome') }
  let(:content_element_type) { Pulitzer::ContentElementType.find_by name: 'Text'}
  let(:ptcet)       { post_type_version.post_type_content_element_types.create(content_element_type_id: content_element_type.id, label: 'A New Field for this Post Type')}

  describe "#call" do

    it "updates a content element in a preview version" do
      ptcet
      Pulitzer::CreatePostContentElements.new(post).call
      preview = post.preview_version
      expect(preview.content_elements.map(&:post_type_content_element_type_id)).to include(ptcet.id)
      ptcet.update label: 'A changed label'
      Pulitzer::UpdatePostTypeContentElements.new(ptcet, 'A New Field for this Post Type').call
      content_element = preview.reload.content_elements.detect{|ce| ce.post_type_content_element_type_id == ptcet.id}
      expect(content_element.label).to eq('A changed label')
    end

    it "doesn't blow up if a post has no preview version" do
      version.update_columns status: 'archived'
      expect(post.reload.preview_version).to be_nil
      # There is no preview version for the post, but we don't blow up
      Pulitzer::UpdatePostTypeContentElements.new(ptcet).call
    end

  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
pulitzer-0.15.31 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.30 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.29 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.28 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.27 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.26 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.25 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.24 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.23 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.22 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.21 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.20 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.19 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.18 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.17 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.16 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.15 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.14 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.13 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.15.12 spec/interactions/update_post_type_content_elements_spec.rb