Sha256: ee669be42e308b56ed85bf5c306a0bd2aa7c0c428ad047c6e59670382a52b349

Contents?: true

Size: 1.97 KB

Versions: 20

Compression:

Stored size: 1.97 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/test_helper")

class TestCollaborators < MiniTest::Unit::TestCase

  def test_delete_collaborator
    with_app do |app_data|
      email_address = 'wesley@heroku.com'
      heroku.post_collaborator(app_data['name'], email_address)

      response = heroku.delete_collaborator(app_data['name'], email_address)

      assert_equal(200, response.status)
      assert_equal(
        "#{email_address} has been removed as collaborator on #{app_data['name']}",
        response.body
      )
    end
  end

  def test_delete_collaborator_app_not_found
    assert_raises(Heroku::API::Errors::NotFound) do
      heroku.delete_collaborator(random_name, random_email_address)
    end
  end

  def test_delete_collaborator_user_not_found
    with_app do |app_data|
      assert_raises(Heroku::API::Errors::NotFound) do
        heroku.delete_collaborator(app_data['name'], random_email_address)
      end
    end
  end

  def test_get_collaborators
    with_app do |app_data|
      response = heroku.get_collaborators(app_data['name'])

      assert_equal(200, response.status)
      assert_equal(
        [{'access' => 'edit', 'email' => app_data['owner_email'], 'name' => nil}],
        response.body
      )
    end
  end

  def test_get_collaborators_app_not_found
    assert_raises(Heroku::API::Errors::NotFound) do
      heroku.get_collaborators(random_name)
    end
  end

  def test_post_collaborator
    with_app do |app_data|
      email_address = 'wesley@heroku.com'
      response = heroku.post_collaborator(app_data['name'], email_address)

      assert_equal(201, response.status)
      assert_equal(
        "#{email_address} added as a collaborator on #{app_data['name']}.",
        response.body
      )

      heroku.delete_collaborator(app_data['name'], email_address)
    end
  end

  def test_post_collaborator_app_not_found
    assert_raises(Heroku::API::Errors::NotFound) do
      heroku.post_collaborator(random_name, random_email_address)
    end
  end

end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
heroku-api-0.3.11 test/test_collaborators.rb
heroku-api-0.3.10 test/test_collaborators.rb
pogoapp-api-0.3.8 test/test_collaborators.rb
heroku-api-0.3.9 test/test_collaborators.rb
heroku-api-0.3.8 test/test_collaborators.rb
heroku-api-0.3.7 test/test_collaborators.rb
heroku-api-0.3.6 test/test_collaborators.rb
heroku-api-0.3.5 test/test_collaborators.rb
heroku-api-0.3.4 test/test_collaborators.rb
heroku-api-0.3.3 test/test_collaborators.rb
heroku-api-0.3.2 test/test_collaborators.rb
heroku-api-0.3.1 test/test_collaborators.rb
heroku-api-0.3.0 test/test_collaborators.rb
heroku-api-0.2.13 test/test_collaborators.rb
heroku-api-0.2.12 test/test_collaborators.rb
heroku-api-0.2.11 test/test_collaborators.rb
heroku-api-0.2.10 test/test_collaborators.rb
heroku-api-0.2.9 test/test_collaborators.rb
heroku-api-0.2.8 test/test_collaborators.rb
heroku-api-0.2.7 test/test_collaborators.rb