diff --git a/lib/travis/api/v3/queries/account.rb b/lib/travis/api/v3/queries/owner.rb similarity index 61% rename from lib/travis/api/v3/queries/account.rb rename to lib/travis/api/v3/queries/owner.rb index 398bd39a..229833f2 100644 --- a/lib/travis/api/v3/queries/account.rb +++ b/lib/travis/api/v3/queries/owner.rb @@ -1,5 +1,5 @@ module Travis::API::V3 - class Queries::Account < Query + class Queries::Owner < Query def find find!(:organization) || find!(:user) end @@ -7,8 +7,8 @@ module Travis::API::V3 private def query(type, main_type: self.main_type, params: self.params) - main_type = type if main_type == :account - params = params.merge("#{type}.login" => params["account.login".freeze]) if params["account.login".freeze] + main_type = type if main_type == :owner + params = params.merge("#{type}.login" => params["owner.login".freeze]) if params["owner.login".freeze] Queries[type].new(params, main_type) end diff --git a/lib/travis/api/v3/renderer/organization.rb b/lib/travis/api/v3/renderer/organization.rb index 00d50b0f..8eab06a8 100644 --- a/lib/travis/api/v3/renderer/organization.rb +++ b/lib/travis/api/v3/renderer/organization.rb @@ -1,6 +1,6 @@ -require 'travis/api/v3/renderer/model_renderer' +require 'travis/api/v3/renderer/owner' module Travis::API::V3 - class Renderer::Organization < Renderer::Account + class Renderer::Organization < Renderer::Owner end end diff --git a/lib/travis/api/v3/renderer/account.rb b/lib/travis/api/v3/renderer/owner.rb similarity index 84% rename from lib/travis/api/v3/renderer/account.rb rename to lib/travis/api/v3/renderer/owner.rb index c69fe61b..1d694b12 100644 --- a/lib/travis/api/v3/renderer/account.rb +++ b/lib/travis/api/v3/renderer/owner.rb @@ -2,7 +2,7 @@ require 'travis/api/v3/renderer/model_renderer' require 'travis/api/v3/renderer/avatar_url' module Travis::API::V3 - class Renderer::Account < Renderer::ModelRenderer + class Renderer::Owner < Renderer::ModelRenderer include Renderer::AvatarURL representation(:minimal, :id, :login) diff --git a/lib/travis/api/v3/renderer/user.rb b/lib/travis/api/v3/renderer/user.rb index 61aa8b1e..992d3f18 100644 --- a/lib/travis/api/v3/renderer/user.rb +++ b/lib/travis/api/v3/renderer/user.rb @@ -1,7 +1,7 @@ -require 'travis/api/v3/renderer/model_renderer' +require 'travis/api/v3/renderer/owner' module Travis::API::V3 - class Renderer::User < Renderer::Account + class Renderer::User < Renderer::Owner representation(:standard, :is_syncing, :synced_at) end end diff --git a/lib/travis/api/v3/routes.rb b/lib/travis/api/v3/routes.rb index bccb414f..1384cf4c 100644 --- a/lib/travis/api/v3/routes.rb +++ b/lib/travis/api/v3/routes.rb @@ -3,8 +3,8 @@ module Travis::API::V3 require 'travis/api/v3/routes/dsl' extend DSL - resource :account do - route '/account/({account.login}|{user.login}|{organization.login})' + resource :owner do + route '/owner/({owner.login}|{user.login}|{organization.login})' get :find end diff --git a/lib/travis/api/v3/services.rb b/lib/travis/api/v3/services.rb index d811d705..0da1369e 100644 --- a/lib/travis/api/v3/services.rb +++ b/lib/travis/api/v3/services.rb @@ -2,11 +2,11 @@ module Travis::API::V3 module Services extend ConstantResolver - Account = Module.new { extend Services } Branch = Module.new { extend Services } Build = Module.new { extend Services } Organization = Module.new { extend Services } Organizations = Module.new { extend Services } + Owner = Module.new { extend Services } Repositories = Module.new { extend Services } Repository = Module.new { extend Services } Requests = Module.new { extend Services } diff --git a/lib/travis/api/v3/services/account/find.rb b/lib/travis/api/v3/services/owner/find.rb similarity index 57% rename from lib/travis/api/v3/services/account/find.rb rename to lib/travis/api/v3/services/owner/find.rb index 88356b12..6751396d 100644 --- a/lib/travis/api/v3/services/account/find.rb +++ b/lib/travis/api/v3/services/owner/find.rb @@ -1,17 +1,17 @@ module Travis::API::V3 - class Services::Account::Find < Service + class Services::Owner::Find < Service def result_type @result_type ||= super end def run! - account = find - @result_type = type_for(account) - account + owner = find + @result_type = type_for(owner) + owner end - def type_for(account) - case account + def type_for(owner) + case owner when Models::User then :user when Models::Organization then :organization end diff --git a/spec/v3/service_index_spec.rb b/spec/v3/service_index_spec.rb index e1e9b6cc..bf49e614 100644 --- a/spec/v3/service_index_spec.rb +++ b/spec/v3/service_index_spec.rb @@ -90,16 +90,16 @@ describe Travis::API::V3::ServiceIndex do end end - describe "account resource" do - let(:resource) { resources.fetch("account") } - specify { expect(resources) .to include("account") } + describe "owner resource" do + let(:resource) { resources.fetch("owner") } + specify { expect(resources) .to include("owner") } specify { expect(resource["@type"]) .to be == "resource" } describe "find action" do let(:action) { resource.fetch("actions").fetch("find") } - specify { expect(action).to include("@type"=>"template", "request_method"=>"GET", "uri_template"=>"#{path}account/{account.login}{?include}") } - specify { expect(action).to include("@type"=>"template", "request_method"=>"GET", "uri_template"=>"#{path}account/{user.login}{?include}") } - specify { expect(action).to include("@type"=>"template", "request_method"=>"GET", "uri_template"=>"#{path}account/{organization.login}{?include}") } + specify { expect(action).to include("@type"=>"template", "request_method"=>"GET", "uri_template"=>"#{path}owner/{owner.login}{?include}") } + specify { expect(action).to include("@type"=>"template", "request_method"=>"GET", "uri_template"=>"#{path}owner/{user.login}{?include}") } + specify { expect(action).to include("@type"=>"template", "request_method"=>"GET", "uri_template"=>"#{path}owner/{organization.login}{?include}") } end end diff --git a/spec/v3/services/account/find_spec.rb b/spec/v3/services/owner/find_spec.rb similarity index 89% rename from spec/v3/services/account/find_spec.rb rename to spec/v3/services/owner/find_spec.rb index d637fc00..6717047f 100644 --- a/spec/v3/services/account/find_spec.rb +++ b/spec/v3/services/owner/find_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -describe Travis::API::V3::Services::Account::Find do +describe Travis::API::V3::Services::Owner::Find do describe "organization" do let(:org) { Organization.new(login: 'example-org') } before { org.save! } after { org.delete } describe 'existing org, public api' do - before { get("/v3/account/example-org") } + before { get("/v3/owner/example-org") } example { expect(last_response).to be_ok } example { expect(JSON.load(body)).to be == { "@type" => "organization", @@ -21,7 +21,7 @@ describe Travis::API::V3::Services::Account::Find do end describe 'it is not case sensitive' do - before { get("/v3/account/example-ORG") } + before { get("/v3/owner/example-ORG") } example { expect(last_response).to be_ok } example { expect(JSON.load(body)).to be == { "@type" => "organization", @@ -39,7 +39,7 @@ describe Travis::API::V3::Services::Account::Find do before { other.save! } after { other.delete } - before { get("/v3/account/example-org?organization.id=#{other.id}") } + before { get("/v3/owner/example-org?organization.id=#{other.id}") } example { expect(last_response).to be_ok } example { expect(JSON.load(body)).to be == { "@type" => "organization", @@ -59,7 +59,7 @@ describe Travis::API::V3::Services::Account::Find do after { user.delete } describe 'existing user, public api' do - before { get("/v3/account/example-user") } + before { get("/v3/owner/example-user") } example { expect(last_response).to be_ok } example { expect(JSON.load(body)).to be == { "@type" => "user", @@ -75,7 +75,7 @@ describe Travis::API::V3::Services::Account::Find do end describe 'it is not case sensitive' do - before { get("/v3/account/example-USER") } + before { get("/v3/owner/example-USER") } example { expect(last_response).to be_ok } example { expect(JSON.load(body)).to be == { "@type" => "user", @@ -95,7 +95,7 @@ describe Travis::API::V3::Services::Account::Find do before { other.save! } after { other.delete } - before { get("/v3/account/example-user?user.id=#{other.id}") } + before { get("/v3/owner/example-user?user.id=#{other.id}") } example { expect(last_response).to be_ok } example { expect(JSON.load(body)).to be == { "@type" => "user",