Sha256: af9412bd35f0ebe53edf4e7236b12821836fb4dafbb0de834f1f41b884fc891c

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require "test_helper"

=begin

  What's being tested here?

    - HasManyThrough

=end

class Admin::ProjectsControllerTest < ActionController::TestCase

  setup do
    @typus_user = Factory(:typus_user)
    @request.session[:typus_user_id] = @typus_user.id

    @project = Factory(:project)
    @user = @project.user
  end

  should_eventually "be able to destroy items" do
    get :destroy, { :id => @user.id, :method => :delete }

    assert_response :redirect
    assert_equal "User successfully removed.", flash[:notice]
    assert_redirected_to :action => :index
  end

  context "relate colaborators to project" do

    setup do
      @request.env['HTTP_REFERER'] = "/admin/projects/edit/#{@project.id}"
    end

    should "work" do
      user = Factory(:user)

      assert_difference('@project.collaborators.count') do
        post :relate, { :id => @project.id,
                        :related => { :model => 'User', :id => user.id, :association_name => 'collaborators' } }
      end

      assert_response :redirect
      assert_redirected_to @request.env['HTTP_REFERER']
      assert_equal "Project successfully updated.", flash[:notice]
    end

    should_eventually "not allow to add collaborator twice"

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typus-3.0.8 test/app/controllers/admin/projects_controller_test.rb
typus-3.0.7 test/app/controllers/admin/projects_controller_test.rb