Skip to content

Commit

Permalink
Creating tests for the :skip_xhr_request parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tscolari committed Sep 16, 2011
1 parent bb127c2 commit 802636c
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/controllers/skip_xhr_request_controller_spec.rb
@@ -0,0 +1,17 @@
require 'spec_helper'

describe SkipXhrRequestController do
render_views

#######################################################
# Testing XHR requests
describe "XHR Requests" do
it "should not use mobile format for xhr requests" do
force_mobile_request_agent("Android")
xhr :get, :index
response.should render_template(:index)
response.body.should contain("this is the mobile view")
end
end

end
2 changes: 2 additions & 0 deletions spec/dummy/app/assets/javascripts/skip_xhr_request.js
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
4 changes: 4 additions & 0 deletions spec/dummy/app/assets/stylesheets/skip_xhr_request.css
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
7 changes: 7 additions & 0 deletions spec/dummy/app/controllers/skip_xhr_request_controller.rb
@@ -0,0 +1,7 @@
class SkipXhrRequestController < ApplicationController
respond_to_mobile_requests :skip_xhr_requests => false

def index
end

end
2 changes: 2 additions & 0 deletions spec/dummy/app/helpers/skip_xhr_request_helper.rb
@@ -0,0 +1,2 @@
module SkipXhrRequestHelper
end
9 changes: 9 additions & 0 deletions spec/dummy/app/views/skip_xhr_request/index.html.erb
@@ -0,0 +1,9 @@
<% unless is_mobile_view? %>
this is the html view
<% end %>
<% if is_mobile_request? %>
THIS A MOBILE DEVICE
<% else %>
THIS IS NOT A MOBILE DEVICE
<% end %>
1 change: 1 addition & 0 deletions spec/dummy/app/views/skip_xhr_request/index.js.erb
@@ -0,0 +1 @@
AJAX VIEW
9 changes: 9 additions & 0 deletions spec/dummy/app/views/skip_xhr_request/index.mobile.erb
@@ -0,0 +1,9 @@
<% if is_mobile_view? %>
this is the mobile view
<% end %>
<% if is_mobile_request? %>
THIS A MOBILE DEVICE
<% else %>
THIS IS NOT A MOBILE DEVICE
<% end %>
2 changes: 2 additions & 0 deletions spec/dummy/config/routes.rb
@@ -1,5 +1,7 @@
Dummy::Application.routes.draw do

get "skip_xhr_request/index"

get "fallbacks/index"

get "testing" => "testing#index"
Expand Down

0 comments on commit 802636c

Please sign in to comment.