class TravisProject < Project

  attr_accessible :travis_github_account, :travis_repository
  validates_presence_of :travis_github_account, :travis_repository, unless: ->(project) { project.webhooks_enabled }

  BASE_HTML_URL = 'https://travis-ci.org'

  def feed_url
    "#{base_url}/builds.json"
  end

  def build_status_url
    feed_url
  end

  def current_build_url
    base_url
  end

  def project_name
    travis_github_account
  end

  def fetch_payload
    TravisJsonPayload.new
  end

  def webhook_payload
    TravisJsonPayload.new
  end

  private

  def base_url
    if webhooks_enabled?
      parsed_url
    else
      "#{BASE_HTML_URL}/#{travis_github_account}/#{travis_repository}"
    end
  end

end

class TravisProject < Project

  attr_accessible :travis_github_account, :travis_repository
  validates_presence_of :travis_github_account, :travis_repository, unless: ->(project) { project.webhooks_enabled }

  def feed_url
    "#{base_url}/builds.json"
  end

  def build_status_url
    feed_url
  end

  def current_build_url
    base_url
  end

  def project_name
    travis_github_account
  end

  def fetch_payload
    TravisJsonPayload.new
  end

  def webhook_payload
    TravisJsonPayload.new
  end

  private

  def base_url
    if webhooks_enabled?
      parsed_url
    else
      "https://api.travis-ci.org/repositories/#{travis_github_account}/#{travis_repository}"
    end
  end

end

Revert "base url changed to link to html page on travis CI, not json"
Revert "base url changed to link to html page on travis CI, not json"

This reverts commit d3d6b228860c15be3c4eb91b4c78bb133e501da2.
