+++ /dev/null
-module ControllerMacros
- def list_should_return_filer_or_json action, params = {}
- # html\8c`\8e®:
- # \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
- # filer\83e\83\93\83v\83\8c\81[\83g\82ð\95`\89æ\82·\82é
- get action, params
- response.should be_success
- response.should render_template("templates/r/filer/filer")
- # json\8c`\8e®
- # \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
- # json\83f\81[\83^\82ð\95Ô\82·
- get action, params.merge(:format => :json)
- response.should be_success
- lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
- end
-
- def announce_sign_in_at_get action, params = {}
- # html\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h302 Found\82ð\95Ô\82·
- get action, params
- response.status.should eq 302
- response.should redirect_to '/users/sign_in'
- # json\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h401 Unauthorized\82ð\95Ô\82·
- get action, params.merge(:format => :json)
- response.status.should eq 401
- response.message.should match(/Unauthorized/)
- end
-
- def return_ok_at_get action, params = {}
- # html\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
- get action, params
- response.should be_success
- # json\8c`\8e®: \83X\83e\81[\83^\83X\83R\81[\83h200 OK\82ð\95Ô\82·
- get action, params.merge(:format => :json)
- response.should be_success
- end
-
-end
-