I''m trying to constrain access to admin routes in my application to either www or canonical. I need the custom constraint in root_domain.rb (RootDomain) to handle the canonical part. Since the subdomains will represent accounts, I don''t want /admin available on any of the subdomains. Here is a gist showing exactly how my code and tests are setup: https://gist.github.com/712968 In the first test, I expect /admin not to be routable on a generic subdomain (this test currently doesn''t pass). However, when I check in a browser, I receive a not routable error. If I remove the custom constraint and use, for example, the :subdomain => "www" constraint, the test does pass. I''ve tested both the custom constraint and the subdomain constraint in my browser and both restrict access as expected. Is this an issue with rspec and how it handles constraints or am I doing something wrong?
Evgeniy Dolzhenko
2010-Nov-25 13:03 UTC
[rspec-users] rspec2, rails 3, subdomain constraints
https://rails.lighthouseapp.com/projects/8994/tickets/5805-assert_recognizes-does-not-support-constraints anyone? On Wed, Nov 24, 2010 at 5:12 AM, jrbruce <jrbruce at gmail.com> wrote:> I''m trying to constrain access to admin routes in my application to > either www or canonical. I need the custom constraint in > root_domain.rb (RootDomain) to handle the canonical part. Since the > subdomains will represent accounts, I don''t want /admin available on > any of the subdomains. > > Here is a gist showing exactly how my code and tests are setup: > > https://gist.github.com/712968 > > In the first test, I expect /admin not to be routable on a generic > subdomain (this test currently doesn''t pass). However, when I check in > a browser, I receive a not routable error. > > If I remove the custom constraint and use, for example, the :subdomain > => "www" constraint, the test does pass. I''ve tested both the custom > constraint and the subdomain constraint in my browser and both > restrict access as expected. > > Is this an issue with rspec and how it handles constraints or am I > doing something wrong? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Nov 25, 5:03?am, Evgeniy Dolzhenko <dolze... at gmail.com> wrote:> https://rails.lighthouseapp.com/projects/8994/tickets/5805-assert_rec... > anyone? > >I appreciate the reply. Given that these routing constraints are core to my application do you have any suggestions as to how to test this in the meantime? It makes me uneasy to have them sitting there completely untested as this point. John> > > On Wed, Nov 24, 2010 at 5:12 AM, jrbruce <jrbr... at gmail.com> wrote: > > I''m trying to constrain access to admin routes in my application to > > either www or canonical. I need the custom constraint in > > root_domain.rb (RootDomain) to handle the canonical part. Since the > > subdomains will represent accounts, I don''t want /admin available on > > any of the subdomains. > > > Here is a gist showing exactly how my code and tests are setup: > > >https://gist.github.com/712968 > > > In the first test, I expect /admin not to be routable on a generic > > subdomain (this test currently doesn''t pass). However, when I check in > > a browser, I receive a not routable error. > > > If I remove the custom constraint and use, for example, the :subdomain > > => "www" constraint, the test does pass. I''ve tested both the custom > > constraint and the subdomain constraint in my browser and both > > restrict access as expected. > > > Is this an issue with rspec and how it handles constraints or am I > > doing something wrong? > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users