Skip to content

Commit

Permalink
use route helper post_url
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry Cheung committed Jun 23, 2014
1 parent 7fa7a68 commit 25f8868
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
10 changes: 0 additions & 10 deletions app/controllers/posts_controller.rb
@@ -1,6 +1,4 @@
class PostsController < ApplicationController
helper_method :permalink_url

# Archive page
#
# @return [Hash] posts keyed by month and year. e.g. 'June 2012'
Expand Down Expand Up @@ -33,12 +31,4 @@ def show
def error
raise "something went wrong"
end

# Returns fully qualified url for given permalink
# @param [URI] permalink
def permalink_url(permalink)
uri = URI.parse(request.url)
uri.path = '/posts' + permalink
uri
end
end
2 changes: 1 addition & 1 deletion app/views/posts/index.xml.builder
Expand Up @@ -12,7 +12,7 @@ xml.rss(:version => "2.0") {
xml.description { xml.cdata!(post.description) }
xml.author("Jerry Cheung")
xml.pubDate(post.date.rfc822)
xml.link(permalink_url(post.permalink))
xml.link(post_url(post.permalink))
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/integration/production_test.rb
Expand Up @@ -65,3 +65,9 @@ class HerokuTest < ActiveSupport::TestCase
assert_equal 'http://www.whatcodecraves.com/', res.headers['Location']
end
end

class GitHubPagesTest < ActiveSupport::TestCase
include ProductionTests

self.base_url = 'http://jch.github.io/'
end

0 comments on commit 25f8868

Please sign in to comment.