Sha256: d52e2293b9f59c9cb47958ea8e6745569638935ef550917dd621d5c87d8866a8

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
# This is free software with ABSOLUTELY NO WARRANTY.
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.

$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
require 'qwik/common-notice'

module Qwik
  class Action
    def c_nerror(title=_('Error'), url=nil, status=500, &b)
     #status = 200 if @config.test
      msg = title
      msg = yield if block_given?
      generate_notice_page(status, title, url, msg)
    end

    def c_notfound(title=_('Not found.'), &b)
      return c_nerror(title, nil, 404, &b)
    end
  end
end

if $0 == __FILE__
  require 'qwik/test-common'
  $test = true
end

if defined?($test) && $test
  class TestCommonError < Test::Unit::TestCase
    include TestSession

    def test_all
      res = session

      @action.c_nerror('c_notice_error title') { 'msg' }
      ok_eq(500, res.status)
      ok_title('c_notice_error title')

      @action.c_nerror
      ok_eq(500, res.status)
      ok_title('Error')

      @action.c_notfound('Not found') { 'msg' }
      ok_eq(404, res.status)
      ok_title('Not found')
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
qwik2md-2.0.1 vendor/qwik/lib/qwik/common-error.rb
qwik2md-2.0.0 vendor/qwik/lib/qwik/common-error.rb
qwik2md-1.0.2 vendor/qwik/lib/qwik/common-error.rb
qwik2md-1.0.1 vendor/qwik/lib/qwik/common-error.rb
qwik2md-1.0.0 vendor/qwik/lib/qwik/common-error.rb
qwik2md-0.1.0 vendor/qwik/lib/qwik/common-error.rb
qwikdoc-0.0.1 vendor/qwik/common-error.rb