Skip to content

Commit

Permalink
Move trans_sid, apply_trans_sid? from ActionController::Base to Actio…
Browse files Browse the repository at this point in the history
…nController::Metal

Signed-off-by: Shin-ichiro OGAWA <rust.stnard+git@gmail.com>
  • Loading branch information
rust committed Oct 26, 2010
1 parent 812331a commit 9f3bbe7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/jpmobile/trans_sid.rb
Expand Up @@ -61,7 +61,7 @@ def redirect_to_with_jpmobile(options = {}, response_status = {})
alias_method_chain :redirect_to, :jpmobile
end

class Base #:nodoc:
class Metal #:nodoc:
class_inheritable_accessor :trans_sid_mode

class << self
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/jpmobile_tasks.rake
Expand Up @@ -98,7 +98,7 @@ END
# ruby "-S bundle install"
ruby "-S rake db:migrate test"
ruby "-S rake spec"
# ruby "-S rspec -b --color spec/requests/filter_spec.rb -e 'jpmobile integration spec HankakuInputFilterController DoCoMo SH902i からのアクセス はtextareaの中では半角に変換されないこと'"
# ruby "-S rspec -b --color spec/requests/trans_sid_spec.rb -e 'trans_sid functional TransSidMetalController という ActionController::Metal のコントローラ で redirect_to がエラーにならない'"

cd relative_root
end
Expand Down
15 changes: 15 additions & 0 deletions test/rails/overrides/app/controllers/trans_sid_metal_controller.rb
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
class TransSidMetalController < ActionController::Metal
include ActionController::RackDelegation
include ActionController::UrlFor
include ActionController::Redirecting
include Rails.application.routes.url_helpers

# 事前にセッションを作成しないと trans_sid が有効にならない
# before_filter :session_init
# trans_sid :always

def redirect
redirect_to('/')
end
end
14 changes: 14 additions & 0 deletions test/rails/overrides/spec/requests/trans_sid_spec.rb
Expand Up @@ -144,6 +144,20 @@ def describe_mobile_with_ua(user_agent, charset, &block)
it_should_behave_like "trans_sid が起動するとき"
end

describe TransSidMetalController, "という ActionController::Metal のコントローラ" do
before(:each) do
@controller = "trans_sid_metal"
@user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"
@charset = "UTF-8"
end

it "で redirect_to がエラーにならない" do
res = get_with_session(@controller, "redirect", @user_agent)

res.response.should be_redirect
end
end

describe TransSidMobileController, "という trans_sid :mobile が指定されているコントローラ" do
before(:each) do
@controller = "trans_sid_mobile"
Expand Down

0 comments on commit 9f3bbe7

Please sign in to comment.