Sha256: a278106f35a1a07d11745b4a027f65d02a406c19247aa2042f3634340b272c55

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe "Manage articles" do

  before do
    @site = Site.make do |s|
      s.articles.make :title => 'news announcement'
    end
    
    @article = @site.articles.first
  end
  
  it "View all articles" do
    # When
    visit articles_path    

    # Then
    should_see "All articles"
    should_see "news announcement"
  end

  it "View a single article" do
    # Given
    visit articles_path
    click_link @article.title

    # Then
    should_see @article.title
    should_see @article.body_source
  end

  it "Create a new article" do
    visit articles_path
    click_link 'New article'
    should_see 'New Article'
    
    # When
    fill_in "Title", :with => "My awesome about article"
    fill_in "Body", :with => "Hello world"
    click_button 'Create article'
    
    # Then
    should_see 'Article was successfully created'
  end
  
  it "Update a article" do
    visit articles_path
    click_link @article.title
    click_link "Edit"
    
    # When
    fill_in "Title", :with => "My awesome about article update"
    fill_in "Body", :with => "Hello world update"
    click_button "Update article"
    
    # Then
    should_see 'Article was successfully update'
    should_see 'Hello world update'
  end
  
  it "Publish a article" do
    visit articles_path
    click_link @article.title
    click_link "Edit"

    select 'publish', :from => 'Status'
    click_button "Update article"
    
    should_see "Article was successfully update"
    should_see "Published at"
  end
  
  it "delete a article" do
    article_title = @article.title.dup
    
    visit articles_path
    click_link article_title
    click_link "Edit"
        
    click_link "Destroy"

    # Rails 3 delete link are js submission
    # response.should_not contain(article_title)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
content_engine-0.1.0 spec/requests/user_manage_articles_spec.rb