Sha256: 8cd44096b08fe428914a4f10ed4d321f0682d6be619471a772151930c7af2e0b

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require "test_helper"

module Shipit
  module Webhooks
    module Handlers
      module PullRequest
        class AssignedHandlerTest < ActiveSupport::TestCase
          test "validates payload" do
            assert_raise(StandardError) { AssignedHandler.new(payload_parsed(:invalid_pull_request)) }
          end

          test "ignores irrelevant PR actions" do
            assert_no_enqueued_jobs do
              AssignedHandler.new(payload_parsed(:pull_request_assigned).merge(action: "labeled")).process
            end
          end

          test "updates the existing PullRequest's assignees" do
            pull_request = shipit_pull_requests(:review_stack_review)
            pull_request.assignees.clear
            payload = payload_parsed(:pull_request_assigned)
            payload["number"] = pull_request.number
            payload["pull_request"]["number"] = pull_request.number

            AssignedHandler.new(payload).process

            assert [shipit_users(:codertocat)], pull_request.reload.assignees
          end

          test "does not attempt to update when PullRequest does not exist" do
            unknown_pull_request_number = 999
            payload = payload_parsed(:pull_request_assigned)
            payload["number"] = unknown_pull_request_number

            assert_no_changes -> { Shipit::PullRequestAssignment.count } do
              AssignedHandler.new(payload).process
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.38.0 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.37.0 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.36.1 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.36.0 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.35.1 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.35.0 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.34.0 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb
shipit-engine-0.33.0 test/models/shipit/webhooks/handlers/pull_request/assigned_handler_test.rb