Sha256: ae4ea5904361b2cf22694fae05f6b59ee54f3a876471856bf08922c29558c11a

Contents?: true

Size: 1.67 KB

Versions: 8

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'

module Shipit
  class StatusGroupTest < ActiveSupport::TestCase
    setup do
      @commit = shipit_commits(:second)
      @group = Status::Group.new(@commit, @commit.statuses_and_check_runs)
    end

    test "#description is a summary of the statuses" do
      assert_equal '2 / 3 checks OK', @group.description
    end

    test "#group? returns true" do
      assert_equal true, @group.group?
    end

    test "#target_url returns nil" do
      assert_nil @group.target_url
    end

    test "#state is significant's status state" do
      assert_equal %w(success success failure), @group.statuses.map(&:state)
      assert_equal 'failure', @group.state
    end

    test "#blocking? returns true if any of the status is blocking" do
      blocking_status = shipit_statuses(:soc_first)
      assert_predicate blocking_status, :blocking?
      Status::Group.new(blocking_status.commit, [blocking_status])
    end

    test ".compact returns a regular status if there is only one visible status" do
      status = Status::Group.compact(@commit, @commit.statuses.where(context: 'ci/travis'))
      assert_instance_of Status, status
    end

    test ".compact returns an unknown status if there is no visible status" do
      status = Status::Group.compact(@commit, @commit.statuses.where(context: 'ci/none'))
      assert_instance_of Status::Unknown, status
    end

    test "missing required status will have MissingRequiredStatus as placeholder" do
      @commit.stubs(:required_statuses).returns(%w(ci/very-important))
      status = Status::Group.compact(@commit, [])
      assert_instance_of Status::Missing, status
      assert_predicate status, :pending?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 test/models/status/group_test.rb
shipit-engine-0.30.0 test/models/status/group_test.rb
shipit-engine-0.29.0 test/models/status/group_test.rb
shipit-engine-0.28.1 test/models/status/group_test.rb
shipit-engine-0.28.0 test/models/status/group_test.rb
shipit-engine-0.27.1 test/models/status/group_test.rb
shipit-engine-0.27.0 test/models/status/group_test.rb
shipit-engine-0.26.0 test/models/status/group_test.rb