Sha256: 023519210e4733e2cc85b0bdc76aa57f37fa3a305f0013cb5dbe8f36da5311b4

Contents?: true

Size: 1.88 KB

Versions: 5

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe "In the dashboard, Snippets", type: :feature do
  before do
    login_admin
  end

  it "lists snippets", js: true do
    3.times{ FactoryGirl.create(:snippet, site: @current_site) }
    visit storytime.dashboard_url
    find("#snippets-link").trigger('click')

    within "#storytime-modal" do
      Storytime::Snippet.all.each do |s|
        expect(page).to have_link(s.name, href: url_for([:edit, :dashboard, s, only_path: true]))
        expect(page).to_not have_content(s.content)
      end
    end
  end

  # it "creates a snippet", js: true, focus: true do
  #   visit storytime.dashboard_url
  #   find("#snippets-link").trigger('click')
  #   click_link "new-snippet-link"
  #
  #   within "#storytime-modal" do
  #     fill_in "snippet_name", with: "jumbotron-text"
  #     find("#snippet_content", visible: false).set("Hooray Writing!")
  #     click_button "Save"
  #   end
  #
  #   within "#storytime-modal" do
  #     require "pry"
  #     binding.pry
  #     expect(page).to have_content "jumbotron-text"
  #   end
  # end

  it "updates a snippet", js: true do
    snippet = FactoryGirl.create(:snippet, site: @current_site, content: "Test")

    visit storytime.dashboard_url
    find("#snippets-link").trigger('click')

    click_link "edit-snippet-#{snippet.id}"

    fill_in "snippet_name", with: "new-name"
    find("#medium-editor-snippet").set("It was a dark and stormy night...")
    click_button "Save"

    within "#storytime-modal" do
      expect(page).to have_content "new-name"
    end
  end

  it "deletes a snippet", js: true do
    snippet = FactoryGirl.create :snippet, site: @current_site

    visit storytime.dashboard_url
    find("#snippets-link").trigger('click')

    find("#snippet_#{snippet.id}").hover()
    click_link "delete_snippet_#{snippet.id}"

    within "#storytime-modal" do
      expect(page).to_not have_content snippet.name
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storytime-2.1.6 spec/features/dashboard/snippets_spec.rb
storytime-2.1.5 spec/features/dashboard/snippets_spec.rb
storytime-2.1.4 spec/features/dashboard/snippets_spec.rb
storytime-2.1.3 spec/features/dashboard/snippets_spec.rb
storytime-2.1.2 spec/features/dashboard/snippets_spec.rb