Sha256: 64ab1c8825a443a79f4c1e4ff7eaad64bbc3727155b21d187ca745e388d36ca2
Contents?: true
Size: 1.95 KB
Versions: 6
Compression:
Stored size: 1.95 KB
Contents
module Heroku class API module Mock # stub DELETE /apps/:app/collaborators/:email Excon.stub(:expects => 200, :method => :delete, :path => %r{^/apps/([^/]+)/collaborators/([^/]+)$}) do |params| request_params, mock_data = parse_stub_params(params) app, email, _ = request_params[:captures][:path] with_mock_app(mock_data, app) do if collaborator_data = get_mock_collaborator(mock_data, app, email) mock_data[:collaborators][app].delete(collaborator_data) { :body => "#{email} has been removed as collaborator on #{app}", :status => 200 } else { :body => 'User not found.', :status => 404 } end end end # stub GET /apps/:app/:collaborators Excon.stub(:expects => 200, :method => :get, :path => %r{^/apps/([^/]+)/collaborators}) do |params| request_params, mock_data = parse_stub_params(params) app, _ = request_params[:captures][:path] with_mock_app(mock_data, app) do { :body => Heroku::API::OkJson.encode(mock_data[:collaborators][app]), :status => 200 } end end # stub POST /apps/:app/collaborators Excon.stub(:expects => 200, :method => :post, :path => %r{^/apps/([^/]+)/collaborators}) do |params| request_params, mock_data = parse_stub_params(params) app, _ = request_params[:captures][:path] email = request_params[:query]['collaborator[email]'] with_mock_app(mock_data, app) do mock_data[:collaborators][app] |= [{'access' => 'edit', 'email' => email}] { :body => "#{email} added as a collaborator on #{app}.", :status => 200 } # Existing user response #{ # :body => "#{email} added as a collaborator on #{app}", # :status => 200 #} end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems