Sha256: e3ce494e338f0b80ae30696347f25e6c261b5cb5c2bed6afec77bfa9910257c5

Contents?: true

Size: 1.65 KB

Versions: 6

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

feature "Resources index" do
  background do
    sign_in
  end

  scenario "Visit the index view of resource" do
    visit_blogs_page
    page_should_have_valid_table
  end

  scenario "Multiple pages for items with more than 30 items" do
    given_31_blog_items
    visit_blogs_page
    page.should have_css("tbody tr", :count => 30)
    click_link "Next"
    page.should have_css("tbody tr", :count => 1)
  end

  scenario "Editable paginate count" do
    given_10_per_page
    given_31_blog_items
    visit_blogs_page
    page_should_have_n_rows 10
  end

  scenario "Filter by 'featured'" do
    given_31_blog_items
    visit_blogs_page
    select "true", from: "Featured"
    click_button "Search"
    page_should_have_n_rows 6
  end

  scenario "Filter by author" do
    given_20_blogs_from_two_authors
    visit_blogs_page
    select "Bob", from: "Author"
    click_button "Search"
    page_should_have_n_rows 9
  end

  def visit_blogs_page
    click_link "Blogs"
  end

  def page_should_have_valid_table
    within ".panel" do
      page.should have_content "Blogs"
      page.should have_content "Name"
      page.should have_content "Body"
      page.should have_no_content "created_at"
    end
  end

  def page_should_have_n_rows(n)
    page.should have_css("tbody tr", :count => n)
  end

  def given_31_blog_items
    25.times { create :blog }
    6.times { create :featured_blog }
  end

  def given_20_blogs_from_two_authors
    create(:author_with_blogs, blogs_count: 11, name: "Alice")
    create(:author_with_blogs, blogs_count: 9, name: "Bob")
  end

  def given_10_per_page
    Brightcontent::BlogsController.class_eval { per_page 10 }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
brightcontent-core-2.1.5 spec/features/resources_index_spec.rb
brightcontent-core-2.1.4 spec/features/resources_index_spec.rb
brightcontent-core-2.1.3 spec/features/resources_index_spec.rb
brightcontent-core-2.1.2 spec/features/resources_index_spec.rb
brightcontent-core-2.1.1 spec/features/resources_index_spec.rb
brightcontent-core-2.1.0 spec/features/resources_index_spec.rb