Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug about If-Modified-Since header #7

Merged
merged 1 commit into from Nov 12, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion misc/plugin/rss.rb
Expand Up @@ -94,7 +94,7 @@ def rss
if_modified_since = nil
end

if if_modified_since and last_modified < if_modified_since
if if_modified_since and last_modified <= if_modified_since
header['status'] = 'NOT_MODIFIED'
return ::Hiki::Response.new('', 304, header)
else
Expand Down
48 changes: 48 additions & 0 deletions test/test_plugin_rss.rb
@@ -0,0 +1,48 @@
# To do: Handle Exception raised in Time.parse line 92

require 'test/unit'
require 'time'
require 'cgi'
require 'rack'
require File.join(File.dirname(__FILE__), *%w[.. hiki request])
require File.join(File.dirname(__FILE__), *%w[.. hiki response])

class Plugin_RSS_Unit_Tests < Test::Unit::TestCase
def setup
@now = Time.parse(CGI.rfc1123_date(Time.now))
@request = Object.new
class << @request
def params; {}; end
end
@conf = Object.new
class << @conf
def charset; end
def lang; end
end
plugin_file = File.expand_path(File.join(File.dirname(__FILE__), *%w{.. misc plugin rss.rb}))
instance_eval(File.read(plugin_file))
class << self
define_method(:rss_body) {|*page_num| ['', @now]}
end
end

def test_rss_returns_304_when_if_modified_since_is_same_to_last_modified
ENV['HTTP_IF_MODIFIED_SINCE'] = CGI.rfc1123_date(@now)
assert_equal 304, rss.status
end

def add_body_enter_proc(prcedure)
end

def add_header_proc(procedure)
end

def add_conf_proc(plugin_name, procedure)
end

def export_plugin_methods(*args)
end

def label_rss_config
end
end