From 353b5fa5027b4adbe5576ff18b6ec27254668dc5 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sat, 17 Nov 2012 21:05:38 +0100 Subject: [PATCH] use registered services --- Gemfile.lock | 30 +++++++++++------------ lib/travis/api/app/endpoint/accounts.rb | 2 +- lib/travis/api/app/endpoint/artifacts.rb | 2 +- lib/travis/api/app/endpoint/branches.rb | 2 +- lib/travis/api/app/endpoint/broadcasts.rb | 2 +- lib/travis/api/app/endpoint/builds.rb | 4 +-- lib/travis/api/app/endpoint/events.rb | 2 +- lib/travis/api/app/endpoint/hooks.rb | 4 +-- lib/travis/api/app/endpoint/jobs.rb | 4 +-- lib/travis/api/app/endpoint/repos.rb | 14 +++++------ lib/travis/api/app/endpoint/requests.rb | 2 +- lib/travis/api/app/endpoint/stats.rb | 4 +-- lib/travis/api/app/endpoint/users.rb | 6 ++--- lib/travis/api/app/endpoint/workers.rb | 4 +-- spec/integration/v2/hooks_spec.rb | 2 +- spec/unit/endpoint/repos_spec.rb | 5 ++++ spec/unit/endpoint/repositories_spec.rb | 5 ---- 17 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 spec/unit/endpoint/repos_spec.rb delete mode 100644 spec/unit/endpoint/repositories_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index 2bd35cc0..9507a84f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,10 +6,10 @@ GIT GIT remote: git://github.com/getsentry/raven-ruby.git - revision: 97bbe7211308d1eb1502df4545592c11e56908ae + revision: 3cd6f4746e7f111d1e835c7f4c8142aee9d7df03 specs: sentry-raven (0.3.1) - faraday (~> 0.8.0.rc2) + faraday (>= 0.7.6) hashie multi_json (~> 1.0) uuidtools @@ -63,7 +63,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-sidekiqs.git - revision: 33cf6b1ed576231c1cc5368f734171b4edd4768b + revision: 4959bd0c3454b98cbf18a5f506f8f33a9a63689d specs: travis-sidekiqs (0.0.1) sentry-raven @@ -71,7 +71,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: ce25da5b53d2dbb67798084a87e91b84f5626061 + revision: f78d9161369f574f12b9c0c0dbfe13b997766bdd specs: travis-support (0.0.1) @@ -132,7 +132,7 @@ GEM coderay (1.0.8) connection_pool (0.9.2) daemons (1.1.9) - dalli (2.3.0) + dalli (2.5.0) data_migrations (0.0.1) activerecord rake @@ -169,7 +169,7 @@ GEM avl_tree (~> 1.1.2) hitimes (~> 1.1) mime-types (1.19) - mocha (0.12.7) + mocha (0.13.0) metaclass (~> 0.0.1) multi_json (1.3.7) multipart-post (1.1.5) @@ -219,21 +219,21 @@ GEM rerun (0.7.1) listen rollout (1.1.0) - rspec (2.11.0) - rspec-core (~> 2.11.0) - rspec-expectations (~> 2.11.0) - rspec-mocks (~> 2.11.0) - rspec-core (2.11.1) - rspec-expectations (2.11.3) + rspec (2.12.0) + rspec-core (~> 2.12.0) + rspec-expectations (~> 2.12.0) + rspec-mocks (~> 2.12.0) + rspec-core (2.12.0) + rspec-expectations (2.12.0) diff-lcs (~> 1.1.3) - rspec-mocks (2.11.3) - sidekiq (2.5.2) + rspec-mocks (2.12.0) + sidekiq (2.5.3) celluloid (~> 0.12.0) connection_pool (~> 0.9.2) multi_json (~> 1) redis (~> 3) redis-namespace - signature (0.1.6) + signature (0.1.4) simple_states (0.1.1) activesupport hashr (~> 0.0.10) diff --git a/lib/travis/api/app/endpoint/accounts.rb b/lib/travis/api/app/endpoint/accounts.rb index 59fe49d6..c8611c71 100644 --- a/lib/travis/api/app/endpoint/accounts.rb +++ b/lib/travis/api/app/endpoint/accounts.rb @@ -4,7 +4,7 @@ class Travis::Api::App class Endpoint class Accounts < Endpoint get '/', scope: :private do - respond_with service(:users, :find_accounts, params), type: :accounts + respond_with service(:find_user_accounts, params), type: :accounts end end end diff --git a/lib/travis/api/app/endpoint/artifacts.rb b/lib/travis/api/app/endpoint/artifacts.rb index e7e22271..43fb9040 100644 --- a/lib/travis/api/app/endpoint/artifacts.rb +++ b/lib/travis/api/app/endpoint/artifacts.rb @@ -7,7 +7,7 @@ class Travis::Api::App class Artifacts < Endpoint # Fetches an artifact by it's *id*. get '/:id' do |id| - respond_with service(:artifacts, :find_one, params) + respond_with service(:find_artifact, params) end end end diff --git a/lib/travis/api/app/endpoint/branches.rb b/lib/travis/api/app/endpoint/branches.rb index 9d97efdd..5f071bd6 100644 --- a/lib/travis/api/app/endpoint/branches.rb +++ b/lib/travis/api/app/endpoint/branches.rb @@ -4,7 +4,7 @@ class Travis::Api::App class Endpoint class Branches < Endpoint get '/' do - respond_with service(:branches, :find_all, params), type: :branches + respond_with service(:find_branches, params), type: :branches end # get '/:owner_name/:name/branches' do # v1 diff --git a/lib/travis/api/app/endpoint/broadcasts.rb b/lib/travis/api/app/endpoint/broadcasts.rb index 5226e5d6..6f5a5543 100644 --- a/lib/travis/api/app/endpoint/broadcasts.rb +++ b/lib/travis/api/app/endpoint/broadcasts.rb @@ -4,7 +4,7 @@ class Travis::Api::App class Endpoint class Broadcasts < Endpoint get '/', scope: :private do - respond_with service(:users, :find_broadcasts, params), type: :broadcasts + respond_with service(:find_user_broadcasts, params), type: :broadcasts end end end diff --git a/lib/travis/api/app/endpoint/builds.rb b/lib/travis/api/app/endpoint/builds.rb index 2357a596..fe7b21c4 100644 --- a/lib/travis/api/app/endpoint/builds.rb +++ b/lib/travis/api/app/endpoint/builds.rb @@ -4,11 +4,11 @@ class Travis::Api::App class Endpoint class Builds < Endpoint get '/' do - respond_with service(:builds, :find_all, params) + respond_with service(:find_builds, params) end get '/:id' do - respond_with service(:builds, :find_one, params) + respond_with service(:find_build, params) end end end diff --git a/lib/travis/api/app/endpoint/events.rb b/lib/travis/api/app/endpoint/events.rb index db46ef2f..47d43fc5 100644 --- a/lib/travis/api/app/endpoint/events.rb +++ b/lib/travis/api/app/endpoint/events.rb @@ -4,7 +4,7 @@ class Travis::Api::App class Endpoint class Events < Endpoint get '/' do - respond_with service(:events, :find_all, params), type: :events + respond_with service(:find_events, params), type: :events end end end diff --git a/lib/travis/api/app/endpoint/hooks.rb b/lib/travis/api/app/endpoint/hooks.rb index 33b5a698..3b21f8d0 100644 --- a/lib/travis/api/app/endpoint/hooks.rb +++ b/lib/travis/api/app/endpoint/hooks.rb @@ -4,11 +4,11 @@ class Travis::Api::App class Endpoint class Hooks < Endpoint get '/', scope: :private do - respond_with service(:hooks, :find_all, params), type: :hooks + respond_with service(:find_hooks, params), type: :hooks end put '/:id?', scope: :private do - respond_with service(:hooks, :update, id: params[:id] || params[:hook][:id], active: params[:hook][:active]) + respond_with service(:update_hook, id: params[:id] || params[:hook][:id], active: params[:hook][:active]) end end end diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 0fd7f4f0..de02c291 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -4,11 +4,11 @@ class Travis::Api::App class Endpoint class Jobs < Endpoint get '/' do - respond_with service(:jobs, :find_all, params) + respond_with service(:find_jobs, params) end get '/:id' do - respond_with service(:jobs, :find_one, params) + respond_with service(:find_job, params) end end end diff --git a/lib/travis/api/app/endpoint/repos.rb b/lib/travis/api/app/endpoint/repos.rb index 40f14995..42f97e4b 100644 --- a/lib/travis/api/app/endpoint/repos.rb +++ b/lib/travis/api/app/endpoint/repos.rb @@ -9,31 +9,31 @@ class Travis::Api::App # owned by johndoe by adding `owner_name=johndoe`, or all repositories that johndoe has access to by adding # `member=johndoe`. The parameter names correspond to the keys of the response hash. get '/' do - respond_with service(:repositories, :find_all, params) + respond_with service(:find_repos, params) end get '/:id' do - respond_with service(:repositories, :find_one, params) + respond_with service(:find_repo, params) end get '/:id/cc' do - respond_with service(:repositories, :find_one, params.merge(schema: 'cc')) + respond_with service(:find_repo, params.merge(schema: 'cc')) end get '/:owner_name/:name' do - respond_with service(:repositories, :find_one, params) + respond_with service(:find_repo, params) end get '/:owner_name/:name/builds' do - respond_with service(:builds, :find_all, params) + respond_with service(:find_builds, params) end get '/:owner_name/:name/builds/:id' do - respond_with service(:builds, :find_one, params) + respond_with service(:find_build, params) end get '/:owner_name/:name/cc' do - respond_with service(:repositories, :find_one, params.merge(schema: 'cc')) + respond_with service(:find_repo, params.merge(schema: 'cc')) end end end diff --git a/lib/travis/api/app/endpoint/requests.rb b/lib/travis/api/app/endpoint/requests.rb index 26618d16..2bbaa77b 100644 --- a/lib/travis/api/app/endpoint/requests.rb +++ b/lib/travis/api/app/endpoint/requests.rb @@ -4,7 +4,7 @@ class Travis::Api::App class Endpoint class Requests < Endpoint post '/' do - respond_with service(:requests, :requeue, params) + respond_with service(:requeue_request, params) end end end diff --git a/lib/travis/api/app/endpoint/stats.rb b/lib/travis/api/app/endpoint/stats.rb index c45f6508..79ad7418 100644 --- a/lib/travis/api/app/endpoint/stats.rb +++ b/lib/travis/api/app/endpoint/stats.rb @@ -4,11 +4,11 @@ class Travis::Api::App class Endpoint class Stats < Endpoint get '/repos' do - { :stats => service(:stats, :daily_repos) } + { :stats => service(:find_daily_repos_stats) } end get '/tests' do - { :stats => service(:stats, :daily_tests) } + { :stats => service(:find_daily_tests_stats) } end end end diff --git a/lib/travis/api/app/endpoint/users.rb b/lib/travis/api/app/endpoint/users.rb index 939381b7..3e991d42 100644 --- a/lib/travis/api/app/endpoint/users.rb +++ b/lib/travis/api/app/endpoint/users.rb @@ -24,7 +24,7 @@ class Travis::Api::App end get '/permissions', scope: :private do - respond_with service(:users, :find_permissions), type: :permissions + respond_with service(:find_user_permissions), type: :permissions end # TODO fix url/key generation in ember-data @@ -38,11 +38,11 @@ class Travis::Api::App # end put '/:id?', scope: :private do - respond_with service(:users, :update, params[:user]) + respond_with service(:update_user, params[:user]) end post '/sync', scope: :private do - respond_with service(:users, :sync) + respond_with service(:sync_user) end end end diff --git a/lib/travis/api/app/endpoint/workers.rb b/lib/travis/api/app/endpoint/workers.rb index 073152c9..bb84d038 100644 --- a/lib/travis/api/app/endpoint/workers.rb +++ b/lib/travis/api/app/endpoint/workers.rb @@ -4,11 +4,11 @@ class Travis::Api::App class Endpoint class Workers < Endpoint get '/' do - respond_with service(:workers, :find_all, params) + respond_with service(:find_workers, params) end get '/:id' do - respond_with service(:workers, :find_one, params) + respond_with service(:find_worker, params) end end end diff --git a/spec/integration/v2/hooks_spec.rb b/spec/integration/v2/hooks_spec.rb index 679360db..37f1a931 100644 --- a/spec/integration/v2/hooks_spec.rb +++ b/spec/integration/v2/hooks_spec.rb @@ -24,7 +24,7 @@ describe 'Hooks' do let :payload do { :name => 'travis', - :events => Travis::Services::Github::SetHook::EVENTS, + :events => Travis::Github::Services::SetHook::EVENTS, :active => true, :config => { :user => user.login, :token => user.tokens.first.token, :domain => 'listener.travis-ci.org' } } diff --git a/spec/unit/endpoint/repos_spec.rb b/spec/unit/endpoint/repos_spec.rb new file mode 100644 index 00000000..bbfc9579 --- /dev/null +++ b/spec/unit/endpoint/repos_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Travis::Api::App::Endpoint::Repos do + it 'has to be tested' +end diff --git a/spec/unit/endpoint/repositories_spec.rb b/spec/unit/endpoint/repositories_spec.rb deleted file mode 100644 index d9136437..00000000 --- a/spec/unit/endpoint/repositories_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Travis::Api::App::Endpoint::Repositories do - it 'has to be tested' -end