spec/mixpanel/tracker/middleware_spec.rb in mixpanel-2.0.2 vs spec/mixpanel/tracker/middleware_spec.rb in mixpanel-2.1.0
- old
+ new
@@ -29,10 +29,26 @@
it "should pass through if the document is not text/html content type" do
last_response.body.should == html_document
end
end
-
+
+ describe "Dummy app, handles skip requests properly" do
+ before do
+ setup_rack_application(DummyApp, {:body => html_document, :headers => {"Content-Type" => "text/html"}})
+ end
+
+ it "should not append mixpanel scripts with skip request" do
+ get "/", {}, {"HTTP_SKIP_MIXPANEL_MIDDLEWARE" => true}
+ Nokogiri::HTML(last_response.body).search('script').should be_empty
+ end
+
+ it "should append mixpanel scripts without skip request" do
+ get "/"
+ Nokogiri::HTML(last_response.body).search('script').size.should == 1
+ end
+ end
+
describe "Appending async mixpanel scripts" do
describe "With ajax requests" do
before do
setup_rack_application(DummyApp, {:body => html_document, :headers => {"Content-Type" => "text/html"}})
get "/", {}, {"HTTP_X_REQUESTED_WITH" => "XMLHttpRequest"}