public
Created

adding non-ralisy urls, routes, classes

  • Download Gist
current
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# Existing requests (all working):
 
POST /1/organizations => creates a new Organization
GET /1/organizations => show Organizations
GET /1/organizations/13 => show Organizations[13]
 
# and so on.
 
# Current routes.rb:
 
scope '/1' do
resources :organizations
end
 
# Current tests
 
spec/controllers/organizations_controller_spec.rb:
describe OrganizationsController do
describe '#index' do
it 'should work' do
get '/1/organizations/13'
resonse.should be_ok
end
end
end
 
# Current controllers
 
app/controllers/organizations_controller.rb:
class OrganizationsController < ActionController::Base
def show
end
end
new
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
# New requests (trying to add):
# Note that there is no "partner" entity; this is only URL padding to avoid collisions with the first block.
 
POST /1/partner/subscriptions => creates a new Subscription
GET /1/partner/subscriptions/13 => show Subscriptions[13]
POST /1/partner/resources => creates a new Resource
GET /1/partner/resources/13 => show Resources[13]
 
# Attempted routes.rb:
scope '/1' do
resources :organizations # existing
 
scope '/partner' do
match 'subscriptions(/:action)' => 'partner_subscriptions#show'
end
end
 
# Attempted tests:
 
spec/controllers/partner_subscriptions_controller_spec.rb:
describe PartnerSubscriptionController do
describe '#subscriptions' do
it 'should work' do
get '/1/partner/subscriptions'
response.should be_ok
end
end
end
 
# Attempted controller
app/controllers/partner_subscriptions_controller.rb:
class PartnerSubscriptionsController < ActionController::Base
def show
 
end
end
 
# but this doesn't work
% rspec spec
1) PartnerSubscriptionsController GET /1/partner/subscriptions should work
Failure/Error: get '/1/partner/subscriptions'
AbstractController::ActionNotFound:
The action '/1/partner/subscriptions' could not be found for PartnerSubscriptionsController
# ./spec/controllers/partner_subscriptions_controller_spec.rb:18:in `block (3 levels) in <top (required)>'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.