galakei 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ class Galakei::Filter::Recode < Galakei::Filter::Base
6
6
  end
7
7
 
8
8
  def condition?
9
- request.ssl? && request.au?
9
+ request.ssl? && request.au_browser_6?
10
10
  end
11
11
 
12
12
  def filter
@@ -23,6 +23,14 @@ module Galakei
23
23
  end
24
24
  end
25
25
 
26
+ def au_browser_6?
27
+ /KDDI.* UP\.Browser\/6\./ =~ user_agent && /UP\.Browser\/6\.2_7/ !~ user_agent
28
+ end
29
+
30
+ def different_cookie_in_ssl?
31
+ au? || softbank?
32
+ end
33
+
26
34
  def galakei?
27
35
  docomo? || au? || softbank?
28
36
  end
@@ -19,9 +19,12 @@ module Galakei::SessionIdParameter::InUrl
19
19
  return false unless options.is_a?(Hash) && request
20
20
  return true if request.imode_browser_1_0?
21
21
 
22
+ # cookies on older AU handsets using SSL are unreliable
23
+ return true if request.au_browser_6? && request.ssl?
24
+
22
25
  # au and softbank have two forms of cookies depending on if it is
23
26
  # http or https, so carry over session id when switching protocols
24
27
  return false unless options[:protocol]
25
- (request.au? || request.softbank?) && (request.protocol != options[:protocol])
28
+ request.different_cookie_in_ssl? && (request.protocol != options[:protocol])
26
29
  end
27
30
  end
@@ -21,7 +21,28 @@ module Galakei
21
21
  end
22
22
 
23
23
  def hex
24
- HEX[0] + @color + HEX[1] + HEX[2]
24
+ hex_color = case @color
25
+ when 'maroon'; '800000'
26
+ when 'red'; 'ff0000'
27
+ when 'orange'; 'ffA500'
28
+ when 'yellow'; 'ffff00'
29
+ when 'olive'; '808000'
30
+ when 'purple'; '800080'
31
+ when 'fuchsia'; 'ff00ff'
32
+ when 'white'; 'ffffff'
33
+ when 'lime'; '00ff00'
34
+ when 'green'; '008000'
35
+ when 'navy'; '000080'
36
+ when 'blue'; '0000ff'
37
+ when 'aqua'; '00ffff'
38
+ when 'teal'; '008080'
39
+ when 'black'; '000000'
40
+ when 'silver'; 'c0c0c0'
41
+ when 'gray'; '808080'
42
+ when 'black'; '000000'
43
+ else @color
44
+ end
45
+ HEX[0] + hex_color + HEX[1] + HEX[2]
25
46
  end
26
47
 
27
48
  def img_tag(options = {})
@@ -1,5 +1,11 @@
1
1
  require "action_dispatch/middleware/session/abstract_store"
2
2
 
3
+ # Patch the abstract session store to accomplish the following things:
4
+ #
5
+ # - avoid issue https://rails.lighthouseapp.com/projects/8994/tickets/6108-activerecord-session-store-clobbers-params#ticket-6108-2 by using Rack::Request instead of ActionDispatch::Request
6
+ # - session ID in the params overwrites session ID in the cookie
7
+ # - make sure we always set the session ID in SSL in case the handset uses different cookies for HTTP/HTTPS
8
+
3
9
  module ActionDispatch
4
10
  module Session
5
11
  class AbstractStore
@@ -7,9 +13,18 @@ module ActionDispatch
7
13
  def extract_session_id(env)
8
14
  stale_session_check! do
9
15
  request = Rack::Request.new(env)
10
- sid = request.cookies[@key]
11
- sid ||= request.params[@key] unless @cookie_only
12
- sid
16
+ if ! @cookie_only && request.params[@key]
17
+ request.params[@key]
18
+ else
19
+ request.cookies[@key]
20
+ end
21
+ end
22
+ end
23
+
24
+ def set_cookie(request, options)
25
+ original_condition = request.cookie_jar[@key] != options[:value] || !options[:expires].nil?
26
+ if original_condition || (request.ssl? && request.different_cookie_in_ssl?)
27
+ request.cookie_jar[@key] = options
13
28
  end
14
29
  end
15
30
  end
@@ -1,3 +1,3 @@
1
1
  module Galakei
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
@@ -19,6 +19,15 @@ class DocomoCssController < ApplicationController
19
19
  render :inline => html, :layout => true
20
20
  end
21
21
 
22
+ def div
23
+ html = <<-EOD
24
+ <% content_for(:head, stylesheet_link_tag("http://www.galakei.com/external.css")) %>
25
+ <div>test</div>
26
+ EOD
27
+ render :inline => html, :layout => true
28
+ end
29
+
30
+
22
31
  def japanese
23
32
  html = <<-EOD
24
33
  <% content_for(:head, stylesheet_link_tag("docomo_css/simple.css")) %>
@@ -56,4 +65,16 @@ feature 'inlining of css' do
56
65
  visit '/docomo_css/japanese'
57
66
  page.body.should include("ほげ")
58
67
  end
68
+
69
+ %w[#000000 black].each do |s|
70
+ scenario "requesting page with #{s} border", :driver => :docomo do
71
+ FakeWeb.register_uri(:get, 'http://www.galakei.com/external.css', :body => "div { border-top: 1px solid #{s} }")
72
+ visit '/docomo_css/div'
73
+ div = find('img')
74
+ div["width"].should == "100%"
75
+ div["height"].should == "1"
76
+ visit div['src']
77
+ page.body.should include("GIF89a")
78
+ end
79
+ end
59
80
  end
@@ -105,13 +105,19 @@ feature 'session' do
105
105
  end
106
106
  end
107
107
 
108
- scenario 'link https to https for au', :driver => :au do
108
+ scenario 'link https to https for au browser 7.2', :driver => :au_7 do
109
109
  visit "https://www.example.com/sessions/link"
110
110
  click_on 'link'
111
111
  page.should have_content("Session Param: false")
112
112
  end
113
113
 
114
- %w[au softbank].each do |s|
114
+ scenario 'link https to https for au browser 6', :driver => :au do
115
+ visit "https://www.example.com/sessions/link"
116
+ click_on 'link'
117
+ page.should have_content("Session Param: true")
118
+ end
119
+
120
+ %w[au au_7 softbank].each do |s|
115
121
  scenario "link http to https for #{s}", :driver => s.to_sym do
116
122
  visit "http://www.example.com/sessions/secure_link"
117
123
  click_on 'secure_link'
@@ -21,6 +21,10 @@ Capybara.register_driver :au do |app|
21
21
  Capybara::Driver::RackTestWithUserAgent.new(app, "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0")
22
22
  end
23
23
 
24
+ Capybara.register_driver :au_7 do |app|
25
+ Capybara::Driver::RackTestWithUserAgent.new(app, "KDDI-SA3B UP.Browser/6.2_7.2.7.1.K.1.3.101 (GUI) MMP/2.0")
26
+ end
27
+
24
28
  Capybara.register_driver :softbank do |app|
25
29
  Capybara::Driver::RackTestWithUserAgent.new(app, "SoftBank/1.0/943SH/SHJ001/SN*************** Browser/NetFront/3.5 Profile/MIDP-2.0 Configuration/CLDC-1.1")
26
30
  end
data/spec/app/fake.rb CHANGED
@@ -21,6 +21,7 @@ app.initialize!
21
21
 
22
22
  app.routes.draw do
23
23
  match 'session_generation' => "sessions#session_generation"
24
+ match 'galakei/spacer/:color' => 'galakei/spacer#create', :defaults => { :format => :gif } # should be directly using config/routes
24
25
  match ':controller(/:action(/:id))'
25
26
  end
26
27
  class ApplicationController < ActionController::Base; end
@@ -272,6 +272,13 @@ EOD
272
272
  let(:css) { "h1 { border-bottom: 1px solid #000000; } "}
273
273
  it_should_behave_like 'border bottom'
274
274
  end
275
+
276
+ context 'border bottom with !important' do
277
+ let(:css) { "h1 { border-bottom: 1px solid #96ca41 !important; } "}
278
+ it 'applied border bottom' do
279
+ subject.next_sibling.to_s.should == %q[<img src="/galakei/spacer/96ca41" width="100%" height="1">]
280
+ end
281
+ end
275
282
  end
276
283
 
277
284
  context 'border css applied to p' do
@@ -34,6 +34,16 @@ describe Galakei::Request do
34
34
  before { @request = Rack::Request.new(env_for("AU W51SH")) }
35
35
  it_should_behave_like "non-docomo devices"
36
36
  it_should_behave_like "non-softbank devices"
37
+ it_should_behave_like "au devices"
38
+ it("should be browser 6") { @request.should be_au_browser_6 }
39
+ end
40
+
41
+ describe "from AU W54SH" do
42
+ before { @request = Rack::Request.new(env_for("AU W54SA")) }
43
+ it_should_behave_like "non-docomo devices"
44
+ it_should_behave_like "non-softbank devices"
45
+ it_should_behave_like "au devices"
46
+ it("should not be browser 6") { @request.should_not be_au_browser_6 }
37
47
  end
38
48
 
39
49
  describe "from Vodafone 802N" do
@@ -1,21 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Galakei::Spacer do
4
- describe 'initialize' do
5
- it 'should can initialize' do
6
- expect {
7
- described_class.new('#000000')
8
- }.to_not raise_error
4
+ context "#000000" do
5
+ subject { described_class.new("#000000") }
6
+ it { subject.img_tag.should == %Q[<img src='/galakei/spacer/000000' width='100%' height='1'>] }
7
+ it { subject.create.should_not be_nil }
8
+ end
9
+ %w[000000 aqua black blue fuchsia gray green lime maroon navy olive orange purple red silver teal white yellow].each do |s|
10
+ context s do
11
+ subject { described_class.new(s) }
12
+ it { subject.img_tag.should == %Q[<img src='/galakei/spacer/#{s}' width='100%' height='1'>] }
13
+ it { subject.create.should_not be_nil }
9
14
  end
10
15
  end
11
-
12
- describe 'output img_tag' do
13
- subject { described_class.new('#000000').img_tag }
14
- it { should == %q[<img src='/galakei/spacer/000000' width='100%' height='1'>] }
15
- end
16
-
17
- describe 'create image binary' do
18
- subject { described_class.new('#000000').create }
19
- it { should_not be_nil }
20
- end
21
16
  end
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,7 @@ def env_for(device_name)
9
9
  "Firefox" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.16) Gecko/20101130 Firefox/3.5.16",
10
10
  "Docomo SH-06A" => "DoCoMo/2.0 SH06A3(c500;TB;W24H14)" ,
11
11
  "AU W51SH" => "KDDI-SH32 UP.Browser/6.2.0.11.2.1 (GUI) MMP/2.0",
12
+ "AU W54SA" => "KDDI-SA3B UP.Browser/6.2_7.2.7.1.K.1.3.101 (GUI) MMP/2.0",
12
13
  "Vodafone 802N" => "Vodafone/1.0/V802N/NJ001/SN*************** Browser/UP.Browser/7.0.2.1.307 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
13
14
  "Softbank 709SC" => "SoftBank/1.0/709SC/SCJ001/SN*************** Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
14
15
  }[device_name]
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: galakei
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 6
8
- - 2
9
- version: 0.6.2
4
+ prerelease:
5
+ version: 0.6.3
10
6
  platform: ruby
11
7
  authors:
12
8
  - Paul McMahon
@@ -16,7 +12,7 @@ autorequire:
16
12
  bindir: bin
17
13
  cert_chain: []
18
14
 
19
- date: 2011-04-19 00:00:00 +09:00
15
+ date: 2011-04-20 00:00:00 +09:00
20
16
  default_executable:
21
17
  dependencies:
22
18
  - !ruby/object:Gem::Dependency
@@ -27,10 +23,6 @@ dependencies:
27
23
  requirements:
28
24
  - - ">="
29
25
  - !ruby/object:Gem::Version
30
- segments:
31
- - 3
32
- - 0
33
- - 3
34
26
  version: 3.0.3
35
27
  type: :runtime
36
28
  version_requirements: *id001
@@ -42,10 +34,6 @@ dependencies:
42
34
  requirements:
43
35
  - - ">="
44
36
  - !ruby/object:Gem::Version
45
- segments:
46
- - 1
47
- - 2
48
- - 1
49
37
  version: 1.2.1
50
38
  type: :runtime
51
39
  version_requirements: *id002
@@ -57,8 +45,6 @@ dependencies:
57
45
  requirements:
58
46
  - - ">="
59
47
  - !ruby/object:Gem::Version
60
- segments:
61
- - 0
62
48
  version: "0"
63
49
  type: :runtime
64
50
  version_requirements: *id003
@@ -70,8 +56,6 @@ dependencies:
70
56
  requirements:
71
57
  - - ">="
72
58
  - !ruby/object:Gem::Version
73
- segments:
74
- - 0
75
59
  version: "0"
76
60
  type: :runtime
77
61
  version_requirements: *id004
@@ -156,21 +140,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
140
  requirements:
157
141
  - - ">="
158
142
  - !ruby/object:Gem::Version
159
- segments:
160
- - 0
161
143
  version: "0"
162
144
  required_rubygems_version: !ruby/object:Gem::Requirement
163
145
  none: false
164
146
  requirements:
165
147
  - - ">="
166
148
  - !ruby/object:Gem::Version
167
- segments:
168
- - 0
169
149
  version: "0"
170
150
  requirements: []
171
151
 
172
152
  rubyforge_project: galakei
173
- rubygems_version: 1.3.7
153
+ rubygems_version: 1.6.2
174
154
  signing_key:
175
155
  specification_version: 3
176
156
  summary: Japanese feature phones support