Sha256: 5839faff19afca20a74ad39199e3b2aea1e6804226cfa6b0cb8b1e58c3e0f293

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

require 'test_helper'

class Admin::PostsControllerTest <  AdminControllerTestCase
  context 'Admin::PostsController' do
    setup do
      admin_login_as
      @post = Factory(:post)
      @tag1 = Factory(:tag)
      @tag2 = Factory(:tag)
      @post.tags << @tag1
    end
    
    context 'relate a resource' do
      setup do
        put :relate, :id => @post.id, :relationship_name => "tags",
          :related_id => @tag2.id
      end
      
      should respond_with(:redirect)
      should set_the_flash.to("The recored has been related.")
      should_change 'Tagging.count', :by => 1
      
      should 'properly have related the record' do
        assert_contains @post.tags(true), @tag2
      end
    end
    
    context 'unrelate a resource' do
      setup do
        put :unrelate, :id => @post.id, :relationship_name => "tags",
          :related_id => @tag1.id
      end
      
      should respond_with(:redirect)
      should set_the_flash.to("The recored has been unrelated.")
      should_change 'Tagging.count', :by => -1
      
      should 'properly have unrelated the record' do
        assert_does_not_contain @post.tags(true), @tag1
      end
    end
    
    context 'page related' do
      setup do
        get :page_related, :id => @post.id, :relationship_name => "tags", :page => 2
      end
      
      should respond_with(:success)
      should render_template("admin/shared/_collection_table")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aa_associations-0.1.2 test/admin_posts_controller_test.rb
aa_associations-0.1.1 test/admin_posts_controller_test.rb
aa_associations-0.1.0 test/admin_posts_controller_test.rb