Browse files

add specs for chromeframe

fix typo in ChromeFrame itself
remove unneccessary chromeframe meta tags from layouts
  • Loading branch information...
1 parent dc62587 commit 586e23727cf4231bb5faa73d0460cc2b5e55507b @davecocoa davecocoa committed Sep 30, 2012
View
1 app/views/layouts/application.html.haml
@@ -6,7 +6,6 @@
%html{:lang => I18n.locale.to_s, :dir => (rtl?) ? 'rtl' : 'ltr'}
%head
%meta{:charset => 'utf-8'}
- %meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'}
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}
%meta{:name => "description", :content => "Diaspora*"}
View
1 app/views/layouts/blank.haml
@@ -6,7 +6,6 @@
%html{:lang => I18n.locale.to_s, :dir => (rtl?) ? 'rtl' : 'ltr'}
%head
%meta{:charset => 'utf-8'}
- %meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'}
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}
= csrf_meta_tag
View
1 app/views/layouts/post.haml
@@ -6,7 +6,6 @@
%html{:lang => I18n.locale.to_s, :dir => (rtl?) ? 'rtl' : 'ltr'}
%head
%meta{:charset => 'utf-8'}
- %meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'}
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}
%meta{:name => "description", :content => "Diaspora*"}
View
2 lib/rack/chrome_frame.rb
@@ -29,7 +29,7 @@ def call(env)
<body>
<div id="cf-placeholder"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
- <script>CFInstall.check({ node: "cf-placx eholder" #{', destination: "' + @options[:destination] + '" ' if @options[:destination]}});</script>
+ <script>CFInstall.check({ node: "cf-placeholder" #{', destination: "' + @options[:destination] + '" ' if @options[:destination]}});</script>
</body>
</html>
HTML
View
7 spec/helper_methods.rb
@@ -72,4 +72,11 @@ def create_conversation_with_message(sender, recipient_person, subject, text)
Conversation.create!(create_hash)
end
+
+ def get_response_for_user_agent(app, userAgent)
+ env = Rack::MockRequest.env_for('/', "HTTP_USER_AGENT" => userAgent)
+ status, headers, body = app.call(env)
+ body.close if body.respond_to?(:close) # avoids deadlock after 3 tests
+ ActionDispatch::TestResponse.new(status, headers, body)
+ end
end
View
47 spec/lib/rack/chrome_frame_spec.rb
@@ -0,0 +1,47 @@
+# Copyright (c) 2010-2011, Diaspora Inc. This file is
+# licensed under the Affero General Public License version 3 or later. See
+# the COPYRIGHT file.
+require 'spec_helper'
+
+describe Rack::ChromeFrame do
+
+ before :all do
+ @app = Rack::Builder.parse_file(Rails.root.join('config.ru').to_s).first
+ end
+
+ before :each do
+ @response = get_response_for_user_agent(@app, ua_string);
+ end
+
+ subject { @response }
+
+ context "non-IE browser" do
+ let(:ua_string) { "another browser chromeframe" }
+
+ its(:body) { should_not =~ /chrome=1/ }
+ its(:body) { should_not =~ /Diaspora doesn't support your version of Internet Explorer/ }
+ end
+
+ context "IE8 without chromeframe" do
+ let(:ua_string) { "MSIE 8" }
+
+ its(:body) { should_not =~ /chrome=1/ }
+ its(:body) { should_not =~ /Diaspora doesn't support your version of Internet Explorer/ }
+ end
+
+ context "IE7 without chromeframe" do
+ let(:ua_string) { "MSIE 7" }
+
+ its(:body) { should_not =~ /chrome=1/ }
+ its(:body) { should =~ /Diaspora doesn't support your version of Internet Explorer/ }
+ specify {@response.headers["Content-Length"].should == @response.body.length.to_s}
+ end
+
+ context "any IE with chromeframe" do
+ let(:ua_string) { "MSIE number chromeframe" }
+
+ its(:body) { should =~ /chrome=1/ }
+ its(:body) { should_not =~ /Diaspora doesn't support your version of Internet Explorer/ }
+ specify {@response.headers["Content-Length"].should == @response.body.length.to_s}
+ end
+end

0 comments on commit 586e237

Please sign in to comment.