make functional tests for context controller run

This commit is contained in:
Reinier Balt 2012-04-19 15:31:18 +02:00
parent 76340b780c
commit 59a4d5ede0
10 changed files with 225 additions and 182 deletions

View file

@ -47,14 +47,26 @@ class ActionController::TestCase
end
def ajax_create(name)
xhr :post, :create, @controller.class.name.downcase.to_sym => {:name => name}
xhr :post, :create, get_model_class.downcase => {:name => name}
end
def assert_xml_select(*args, &block)
@html_document = xml_document
assert_select(*args, &block)
end
private
def xml_document
@xml_document ||= HTML::Document.new(@response.body, false, true)
end
def get_model_class
@controller.class.to_s.tableize.split("_")[0].camelcase.singularize #don't ask... converts ContextsController to Context
end
def get_class_count
model = @controller.class.to_s.tableize.split("_")[0].camelcase.singularize #don't ask... converts ContextsController to Context
eval("#{model}.count")
eval("#{get_model_class}.count")
end
end