Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Testing GET with parameters

  • Loading branch information...
commit 314e70287984873e9976f47669e7edf3524702cf 1 parent b6a6d61
@gus gus authored
View
2  lib/riot/action_controller/context_middleware.rb
@@ -12,7 +12,7 @@ def call(context)
context.helper(:env) { @env }
context.helper(:controller) { @controller }
context.helper(:request) { @request }
- context.helper(:response) { @response }
+ context.helper(:response) { last_response }
context.setup(true) do
self.class_eval do
View
7 lib/riot/active_record/context_middleware.rb
@@ -9,13 +9,6 @@ def handle?(context)
def call(context)
context.setup(true) { context.description.new }
-
- # context.transaction do |&original_block|
- # ::ActiveRecord::Base.transaction do
- # original_block.call
- # raise ::ActiveRecord::Rollback
- # end
- # end
end
end # ActiveRecordMiddleware
View
39 test/action_controller/get_request_test.rb
@@ -1,17 +1,6 @@
require 'teststrap'
context RoomsController do
- context "for a GET request" do
- setup do
- get "/rooms/index"
- end
-
- asserts("action name") { env['action_dispatch.request.path_parameters'][:action] }.equals("index")
-
- asserts("response status") { response.status }.equals(200)
- asserts("response header") { response.header }.equals("Content-Type" => "text/html")
- asserts("response body") { response.body }.equals("foo")
- end
asserts("unknown action for existing controller") do
get "/rooms/blah"
@@ -20,4 +9,32 @@
asserts("controller does not the one under test") do
get "/gremlins/index"
end.raises(RiotRails::ActionController::ControllerMismatch, "Expected rooms controller, not gremlins")
+
+ context "for a GET request" do
+ helper(:action_name) { env['action_dispatch.request.path_parameters'][:action] }
+
+ context "without with parameters" do
+ setup { get "/rooms/index" }
+
+ asserts("action name") { action_name }.equals("index")
+ asserts("response status") { response.status }.equals(200)
+ asserts("response body") { last_response.body }.equals("foo")
+
+ context "response headers" do
+ setup { response.headers.keys }
+ asserts_topic.includes("Content-Type")
+ asserts_topic.includes("ETag")
+ asserts_topic.includes("Cache-Control")
+ end # response headers
+ end # without with parameters
+
+ context "with parameters" do
+ setup { get "/rooms/echo_params", {:name => "Juiceton", :foo => "blaz"} }
+
+ asserts("action name") { action_name }.equals("echo_params")
+ asserts("response body") { response.body }.equals("foo=blaz,name=Juiceton")
+ end # with with parameters
+
+ end # for a GET request
+
end # RoomsController
View
9 test/rails_root/app/controllers/rooms_controller.rb
@@ -1,3 +1,10 @@
class RoomsController < ActionController::Base
- def index; render :text => "foo"; end
+ def index
+ render :text => "foo"
+ end
+
+ def echo_params
+ serialized_params = (params.keys - ["action"]).sort.map {|k| "#{k}=#{params[k]}" }.join(",")
+ render :text => serialized_params
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.