aboutsummaryrefslogtreecommitdiffstats
path: root/features/support/paths.rb
blob: 1fdf9f84d3a8bba37a3804ac6dec2849b782f0a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module NavigationHelpers
  module Refinery
    module Blog
      def path_to(page_name)
        case page_name
        when /the list of blog posts/
          refinery_admin_blog_posts_path
        when /the new blog posts? form/
          new_refinery_admin_blog_post_path
        else
          begin
            if page_name =~ /the blog post titled "?([^\"]*)"?/ and (page = BlogPost.find_by_title($1)).present?
              self.url_for(page.url)
            else
              nil
            end
          rescue
            nil
          end
        end
      end
    end
  end
end