Changeset 1283
- Timestamp:
- 01/11/08 19:06:36 (9 months ago)
- Files:
-
- trunk/lib/merb/mixins/controller.rb (modified) (1 diff)
- trunk/lib/merb/test/rspec_matchers/controller_matchers.rb (modified) (1 diff)
- trunk/spec/merb/controller_spec.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/merb/mixins/controller.rb
r1228 r1283 65 65 # +url+ - URL to redirect to; it can be either a relative or 66 66 # fully-qualified URL. 67 # +permanent+ - Whether to use permanent redirection. 67 68 # 68 def redirect(url) 69 Merb.logger.info("Redirecting to: #{url}") 70 set_status(302) 69 def redirect(url, permanent = false) 70 status = permanent ? 301 : 302 71 Merb.logger.info("Redirecting to: #{url} status: #{status}") 72 set_status(status) 71 73 headers['Location'] = url 72 74 "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>" trunk/lib/merb/test/rspec_matchers/controller_matchers.rb
r1115 r1283 6 6 def matches?(target) 7 7 @target = target 8 target == 3028 [301, 302].include? target 9 9 end 10 10 def failure_message trunk/spec/merb/controller_spec.rb
r1109 r1283 95 95 def show 96 96 end 97 def permanent 98 redirect("/foo",:permanent) 99 end 97 100 end 98 101 … … 114 117 @controller.should_not redirect_to("/foo") 115 118 end 119 120 it "should be able to match permanent redirects" do 121 @controller.dispatch('permanent') 122 @controller.status.should be_redirect 123 @controller.should redirect 124 @controller.should redirect_to("/foo") 125 end 116 126 end
