{"action":"created","issue":{"url":"https://api.github.com/repos/lotus/controller/issues/93","labels_url":"https://api.github.com/repos/lotus/controller/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/lotus/controller/issues/93/comments","events_url":"https://api.github.com/repos/lotus/controller/issues/93/events","html_url":"https://github.com/lotus/controller/issues/93","id":60419060,"number":93,"title":"#call method is called even when a before callback does a redirect_to.","user":{"login":"donperi","id":999204,"avatar_url":"https://avatars.githubusercontent.com/u/999204?v=3","gravatar_id":"","url":"https://api.github.com/users/donperi","html_url":"https://github.com/donperi","followers_url":"https://api.github.com/users/donperi/followers","following_url":"https://api.github.com/users/donperi/following{/other_user}","gists_url":"https://api.github.com/users/donperi/gists{/gist_id}","starred_url":"https://api.github.com/users/donperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donperi/subscriptions","organizations_url":"https://api.github.com/users/donperi/orgs","repos_url":"https://api.github.com/users/donperi/repos","events_url":"https://api.github.com/users/donperi/events{/privacy}","received_events_url":"https://api.github.com/users/donperi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-03-09T22:10:10Z","updated_at":"2015-03-10T14:39:35Z","closed_at":null,"body":"Hi everyone!\r\n\r\nI'm experimenting some random behaviors.\r\n\r\nI have a `before :authenticate!` callback that redirect to '/login' when a session doesn't exist. Simple.\r\n\r\nWhen making the tests for the action I wanted to check that it returns 302 when user isn't  authenticated.\r\n\r\nWhen running the tests, the tests were running the #call method and calling the Repository when it should stop the chain and redirect.\r\n\r\nHere some examples.\r\n\r\n```ruby\r\nmodule Web::Controllers::Posts\r\n  class Index\r\n    include Web::Action\r\n    # include Web::AuthenticatedAction\r\n\r\n    before :authenticate!\r\n\r\n    def call(params)\r\n      puts  \"This should not be called\"\r\n    end\r\n\r\n    def authenticate!\r\n      puts \"Redirect should stop here\"\r\n      redirect_to '/login'\r\n    end\r\n  end\r\nend\r\n````\r\n\r\nHere is the output when I request the controller route\r\n\r\n```sh\r\n[2015-03-09 18:04:15] INFO  WEBrick 1.3.1\r\n[2015-03-09 18:04:15] INFO  ruby 2.1.4 (2014-10-27) [x86_64-darwin14.0]\r\n[2015-03-09 18:04:15] INFO  WEBrick::HTTPServer#start: pid=49653 port=2300\r\nRedirect should stop here\r\nThis should not be called\r\n::1 - - [09/Mar/2015:18:04:18 -0400] \"GET / HTTP/1.1\" 302 - 0.9164\r\n::1 - - [09/Mar/2015:18:04:19 -0400] \"GET /login HTTP/1.1\" 200 - 0.8267\r\n```\r\n\r\nThe same apply for tests."},"comment":{"url":"https://api.github.com/repos/lotus/controller/issues/comments/78066737","html_url":"https://github.com/lotus/controller/issues/93#issuecomment-78066737","issue_url":"https://api.github.com/repos/lotus/controller/issues/93","id":78066737,"user":{"login":"AlfonsoUceda","id":925961,"avatar_url":"https://avatars.githubusercontent.com/u/925961?v=3","gravatar_id":"","url":"https://api.github.com/users/AlfonsoUceda","html_url":"https://github.com/AlfonsoUceda","followers_url":"https://api.github.com/users/AlfonsoUceda/followers","following_url":"https://api.github.com/users/AlfonsoUceda/following{/other_user}","gists_url":"https://api.github.com/users/AlfonsoUceda/gists{/gist_id}","starred_url":"https://api.github.com/users/AlfonsoUceda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlfonsoUceda/subscriptions","organizations_url":"https://api.github.com/users/AlfonsoUceda/orgs","repos_url":"https://api.github.com/users/AlfonsoUceda/repos","events_url":"https://api.github.com/users/AlfonsoUceda/events{/privacy}","received_events_url":"https://api.github.com/users/AlfonsoUceda/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T14:39:35Z","updated_at":"2015-03-10T14:39:35Z","body":"@luishurtado the problem is that call method is called, then if you have method like search in database the code is executed.\r\n\r\nA clear example is forbid a page an user without privileges, the call method shouldn't be called, IMO"}}