Sha256: fed1e0e240caf7403ad91ce37d8c78013b0afdbe62cdc47c703bb43258935e28

Contents?: true

Size: 1.8 KB

Versions: 10

Compression:

Stored size: 1.8 KB

Contents

require 'commands/commands_helper'
require 'toolshed/commands/push_branch'

class PushBranchTest < Test::Unit::TestCase
  def setup
    Toolshed.expects(:die).at_least(0).returns('Exiting')
    @branch = Toolshed::Git::Branch.new
  end

  def test_push_branch_current_working_branch
    Toolshed::Client.instance.push_to_remote_name = 'origin'

    current_branch = Toolshed::Git::Branch.name

    new_branch_name = random_branch_name
    create_and_checkout_branch(new_branch_name, 'master')

    push_branch_command = Toolshed::Commands::PushBranch.new
    push_branch_command.execute({})

    assert_equal new_branch_name, @branch.name

    Toolshed::Git::Branch.checkout(current_branch)
    delete_branch(new_branch_name)
  end

  def test_push_branch_by_ticket_id
    Toolshed::Client.instance.push_to_remote_name = 'origin'

    current_branch = @branch.name

    new_branch_name = "555558_#{random_branch_name}"
    create_and_checkout_branch(new_branch_name, 'master')

    push_branch_command = Toolshed::Commands::PushBranch.new

    expected_git = Toolshed::Git::Branch.new(branch_name: '555558')
    push_branch_command.execute({}, { branch_name: '555558' })
    assert_equal new_branch_name, expected_git.name

    Toolshed::Git::Branch.checkout(current_branch)
    delete_branch(new_branch_name)
  end

  def test_push_branch_current_working_branch_with_force
    Toolshed::Client.instance.push_to_remote_name = 'origin'

    current_branch = Toolshed::Git::Branch.name

    new_branch_name = random_branch_name
    create_and_checkout_branch(new_branch_name, 'master')

    push_branch_command = Toolshed::Commands::PushBranch.new
    push_branch_command.execute({}, { force: true })

    assert_equal new_branch_name, @branch.name

    Toolshed::Git::Branch.checkout(current_branch)
    delete_branch(new_branch_name)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
toolshed-1.0.12 test/commands/push_branch_test.rb
toolshed-1.0.11 test/commands/push_branch_test.rb
toolshed-1.0.10 test/commands/push_branch_test.rb
toolshed-1.0.9 test/commands/push_branch_test.rb
toolshed-1.0.8 test/commands/push_branch_test.rb
toolshed-1.0.7 test/commands/push_branch_test.rb
toolshed-1.0.6 test/commands/push_branch_test.rb
toolshed-1.0.5 test/commands/push_branch_test.rb
toolshed-1.0.4 test/commands/push_branch_test.rb
toolshed-1.0.3 test/commands/push_branch_test.rb