Class: CC::Service::GitHubPullRequests

Inherits:
CC::Service show all
Defined in:
lib/cc/services/github_pull_requests.rb

Defined Under Namespace

Classes: Config

Constant Summary

Constants inherited from CC::Service

ALL_EVENTS, ConfigurationError, Error

Constants included from Helper

Helper::GREEN_HEX, Helper::RED_HEX

Constants included from HTTP

HTTP::REDIRECT_CODES

Instance Attribute Summary

Attributes inherited from CC::Service

#config, #event, #payload

Instance Method Summary collapse

Methods inherited from CC::Service

by_slug, inherited, #initialize, load_services, #receive, services, slug

Methods included from Helper

#changed, #color, #compare_url, #details_url, #emoji, #hex_color, #improved?, #repo_name

Methods included from HTTP

#ca_file, #formatted_post_response, #http, #http_method, #raw_get, #raw_post, #service_get, #service_post, #service_post_with_redirects

Constructor Details

This class inherits a constructor from CC::Service

Instance Method Details

#receive_pull_requestObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cc/services/github_pull_requests.rb', line 44

def receive_pull_request
  if update_status?
    setup_http
    state = @payload["state"]

    if %w[pending success failure skipped error].include?(state)
      send("update_status_#{state}")
    else
      @response = simple_failure("Unknown state")
    end
  end

  response
end

#receive_pull_request_coverageObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cc/services/github_pull_requests.rb', line 59

def receive_pull_request_coverage
  if update_coverage_status?
    setup_http
    state = @payload["state"]

    if state == "success"
      update_coverage_status_success
    else
      @response = simple_failure("Unknown state")
    end
  end

  response
end

#receive_testObject

Just make sure we can access GH using the configured token. Without additional information (github-slug, PR number, etc) we can’t test much else.



34
35
36
37
38
39
40
41
42
# File 'lib/cc/services/github_pull_requests.rb', line 34

def receive_test
  setup_http

  if update_status?
    receive_test_status
  else
    simple_failure("Nothing happened")
  end
end