Sha256: d763d003af2b444ce3d9b2d328cbfe858307a7010de67c460616e847a15650ee

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

feature "JS Confirmations" do

  given(:admin) { create(:user, super_admin: true) }

  given(:category) { create(:category, num_posts: 0) }
  given(:post) { create(:post, :reviewed, category: category) }

  scenario 'accepting JS confirmation performs action', js: true do
    login_and_navigate_to_post admin, post

    #page.driver.browser.accept_js_confirms
    click_link "Publish Post"

    page.driver.confirm_messages.should include "Do you want to publish now?"
    page.should have_css(".flash.flash_notice", text: "Post successfully published")

    post_should_have_status "published"
  end

  scenario 'rejecting JS confirmatino skips action', js: true do
    login_and_navigate_to_post admin, post

    dismiss_confirm do
      #page.driver.browser.reject_js_confirms
      click_link "Publish Post"

      page.driver.confirm_messages.should include "Do you want to publish now?"
      page.should_not have_css(".flash.flash_notice", text: "Post successfully published")

      post_should_have_status "reviewed"
    end
  end

  scenario 'JS prompt has default transation', js: true do
    login_and_navigate_to_post admin, post

    #page.driver.browser.accept_js_confirms
    click_link "Reopen"

    page.driver.confirm_messages.should include "Are you sure you want to reopen?"
  end

  scenario 'JS prompt uses Proc for message', js: true do
    login_and_navigate_to_post admin, post

    #page.driver.browser.accept_js_confirms
    click_link "Archive"

    page.driver.confirm_messages.should include "Do you want to archive?"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rs-active_admin-state_machine-0.2.1 spec/features/js_confirmation_spec.rb
rs-active_admin-state_machine-0.2.0 spec/features/js_confirmation_spec.rb