Sha256: dd2e900decf6276ac5b9c9618207f7c4a5e31738b184874472b5d3c7d4f0dfde

Contents?: true

Size: 1.6 KB

Versions: 5

Compression:

Stored size: 1.6 KB

Contents

require "spec_helper"

describe "attach page images" do
  refinery_login_with :refinery_user

  # No-op block : use default configuration by default
  let(:configure) {}
  let(:create_page) { FactoryGirl.create(:page) }
  let(:navigate_to_edit)  { click_link "Edit this page" }
  let(:page_images_tab_id) { "#custom_#{::I18n.t(:'refinery.plugins.refinery_page_images.tab_name')}_tab"  }

  let(:setup_and_visit) do
    configure
    create_page
    visit refinery.admin_pages_path
    navigate_to_edit
  end

  it "shows images tab" do
    setup_and_visit
    within page_images_tab_id do
      page.should have_content("Images")
    end
  end

  # This spec actually is broken in a way because Add Image link would
  # be visible to capybara even if we don't click on Images tab.
  it "shows add image link" do
    setup_and_visit
    within page_images_tab_id do
      click_link "Images"
    end

    page.should have_content("Add Image")
  end

  context "with caption and WYSIWYG disabled" do
    let(:configure) do
      Refinery::PageImages.config.wysiwyg  = false
      Refinery::PageImages.config.captions = true
    end

    let(:create_page) { FactoryGirl.create(:page_with_image) }
    let(:navigate_to_edit) { page.find('a[tooltip="Edit this page"]').click }

    it "shows a plain textarea when editing caption", js: true do
      setup_and_visit
      page.find("#{page_images_tab_id} a").click
      image_li_tag = page.find("#page_images li:first-child")

      image_li_tag.hover
      within(image_li_tag) { page.find('img.caption').click }

      page.find('.ui-dialog textarea').should be_visible
    end
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
refinerycms-page-images-2.1.1 spec/features/attach_page_images_spec.rb
refinerycms-page-options-2.1.2 spec/features/attach_page_images_spec.rb
refinerycms-page-options-2.1.1 spec/features/attach_page_images_spec.rb
refinerycms-page-options-2.1.0 spec/features/attach_page_images_spec.rb
refinerycms-page-images-2.1.0 spec/features/attach_page_images_spec.rb