Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Check that all the provided snips can be requested.

  • Loading branch information...
commit 57e46b4c8e7c71274761cc7d26fbb322bdcf192d 1 parent 44eb02d
@lazyatom authored
View
1  lib/vanilla/app.rb
@@ -115,6 +115,7 @@ def rendering_and_handling_errors(snip)
renderer_instance = renderer_for(snip).new(self)
yield renderer_instance
rescue Exception => e
+ response.status = 500
snip_name = snip ? snip.name : nil
"<pre>[Error rendering '#{snip_name}' - \"" +
e.message.gsub("<", "&lt;").gsub(">", "&gt;") + "\"]\n" +
View
1  pristine_app/soups/system/current_snip.rb
@@ -14,6 +14,7 @@ class CurrentSnip < Dynasnip
|
def handle(attribute=nil)
+ return usage if app.request.snip_name == snip_name
if app.request.snip
if attribute ||= app.request.part
%|{"#{app.request.snip_name}"."#{attribute}"}|
View
10 pristine_app/soups/system/link_to.rb
@@ -8,11 +8,13 @@ class LinkTo < Dynasnip
would insert a link to the blah snip.|
- def handle(snip_name, link_text=snip_name, part=nil)
- if app.soup[snip_name]
- %{<a href="#{url_to(snip_name, part)}">#{link_text}</a>}
+ def handle(name=nil, link_text=name, part=nil)
+ return usage if requesting_this_snip?
+ return "You must provide a snip name" unless name
+ if app.soup[name]
+ %{<a href="#{url_to(name, part)}">#{link_text}</a>}
else
- %{<a class="missing" href="#{url_to(snip_name, part)}">#{link_text}</a>}
+ %{<a class="missing" href="#{url_to(name, part)}">#{link_text}</a>}
end
end
View
3  pristine_app/soups/system/pre.rb
@@ -13,7 +13,8 @@ class ShowContentInPreTag < Dynasnip
{pre my_snip,specific_part}
|
- def handle(snip_name, part=:content)
+ def handle(snip_name=nil, part=:content)
+ return usage if requesting_this_snip?
%{<pre>#{app.soup[snip_name].__send__(part || :content)}</pre>}
end
View
3  pristine_app/soups/system/raw.rb
@@ -14,7 +14,8 @@ class ShowRawContent < Dynasnip
{raw my_snip,specific_part}
|
- def handle(snip_name, part=:content)
+ def handle(snip_name=nil, part=:content)
+ return usage if requesting_this_snip?
%{#{Dynasnip.escape_curly_braces(CGI.escapeHTML(app.soup[snip_name].__send__(part || :content)))}}
end
View
21 test/pristine_app/site_test.rb
@@ -0,0 +1,21 @@
+require "test_helper"
+require "timeout"
+
+context "Every snip" do
+ should "return a 200 response code" do
+ snips = app.soup.all_snips
+ snips.each do |snip|
+ expected_code = 200
+ expected_code = 500 if %w(test bad_dynasnip).include?(snip.name)
+ begin
+ Timeout.timeout(1) do
+ get snip.name
+ assert_equal expected_code, last_response.status,
+ "#{snip.name} returned a #{last_response.status} response:\n#{last_response.body}"
+ end
+ rescue Timeout::Error
+ flunk "#{snip.name} timed out rendering"
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.