Sha256: 6d3a81aaa01b0e18a5b4bcc97e11829a782a42c122336ef6e8cf5cd0cfc54ed6

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe "Comments" do
  with_controllers
  set_controller Controllers::Comments
  login_as :user
    
  before do
    @item = Factory.create :item
  end
  
  def create_comment original_text = 'text'
    Factory.create :comment, item: @item, owner: @user
  end
  
  it "should display new dialog" do
    call :new, format: 'js', item_id: @item.to_param
    response.should be_ok
  end
  
  it "should create Comment" do
    comment_attributes = Factory.attributes_for :comment
    pcall :create, format: 'js', item_id: @item.to_param, model: comment_attributes
    response.should be_ok
    
    Models::Comment.count.should == 1
    comment = Models::Comment.first
    comment.original_text.should == comment_attributes[:original_text]
    comment.owner.should == @user
    comment.item.should == @item
  end
  
  it "should display edit dialog" do
    comment = create_comment
    call :edit, format: 'js', id: comment.to_param
    response.should be_ok
  end
  
  it "should update Comment" do
    comment = create_comment
    new_attributes = {original_text: 'new text'}
    pcall :update, format: 'js', id: comment.to_param, model: new_attributes
    response.should be_ok
    
    comment.reload
    comment.original_text.should == 'new text'
  end
  
  it "should delete Comment" do
    comment = create_comment
    pcall :destroy, format: 'js', id: comment.to_param
    Models::Comment.count.should == 0
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rad_kit-0.0.8 spec/controller/comments_spec.rb
rad_kit-0.0.7 spec/controller/comments_spec.rb
rad_kit-0.0.6 spec/controller/comments_spec.rb
rad_kit-0.0.5 spec/controller/comments_spec.rb
rad_kit-0.0.4 spec/controller/comments_spec.rb
rad_kit-0.0.3 spec/controller/comments_spec.rb
rad_kit-0.0.2 spec/controller/comments_spec.rb
rad_kit-0.0.1 spec/controller/comments_spec.rb