Cucumber tag steps now pass.
This commit is contained in:
parent
ded42bc691
commit
164dc27a42
12 changed files with 88 additions and 86 deletions
|
@ -73,10 +73,9 @@ module Refinery
|
|||
def tagged
|
||||
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
|
||||
@tag_name = @tag.name
|
||||
@blog_posts = Refinery::BlogPost.tagged_with(@tag_name).paginate({
|
||||
:page => params[:page],
|
||||
:per_page => Refinery::Setting.find_or_set(:blog_posts_per_page, 10)
|
||||
})
|
||||
@blog_posts = Refinery::BlogPost.tagged_with(@tag_name)
|
||||
.page(params[:page])
|
||||
.per(Refinery::Setting.find_or_set(:blog_posts_per_page, 10))
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -92,10 +91,10 @@ module Refinery
|
|||
end
|
||||
|
||||
def find_all_blog_posts
|
||||
@blog_posts = Refinery::BlogPost.live.includes(:comments, :categories).paginate({
|
||||
:page => params[:page],
|
||||
:per_page => Refinery::Setting.find_or_set(:blog_posts_per_page, 10)
|
||||
})
|
||||
@blog_posts = Refinery::BlogPost.live
|
||||
.includes(:comments, :categories)
|
||||
.page(params[:page])
|
||||
.per(Refinery::Setting.find_or_set(:blog_posts_per_page, 10))
|
||||
end
|
||||
|
||||
def find_tags
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Refinery
|
||||
class BlogController < ::ApplicationController
|
||||
|
||||
helper :blog_posts
|
||||
helper :'refinery/blog_posts'
|
||||
before_filter :find_page, :find_all_blog_categories
|
||||
|
||||
protected
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
module BlogPostsHelper
|
||||
def blog_archive_list
|
||||
posts = BlogPost.select('published_at').all_previous
|
||||
return nil if posts.blank?
|
||||
html = '<section id="blog_archive_list"><h2>'
|
||||
html << t('archives', :scope => 'blog.shared')
|
||||
html << '</h2><nav><ul>'
|
||||
links = []
|
||||
super_old_links = []
|
||||
|
||||
posts.each do |e|
|
||||
if e.published_at >= Time.now.end_of_year.advance(:years => -3)
|
||||
links << e.published_at.strftime('%m/%Y')
|
||||
else
|
||||
super_old_links << e.published_at.strftime('01/%Y')
|
||||
end
|
||||
end
|
||||
links.uniq!
|
||||
super_old_links.uniq!
|
||||
links.each do |l|
|
||||
year = l.split('/')[1]
|
||||
month = l.split('/')[0]
|
||||
count = BlogPost.by_archive(Time.parse(l)).size
|
||||
text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
|
||||
html << "<li>"
|
||||
html << link_to(text, archive_blog_posts_path(:year => year, :month => month))
|
||||
html << "</li>"
|
||||
end
|
||||
super_old_links.each do |l|
|
||||
year = l.split('/')[1]
|
||||
count = BlogPost.by_year(Time.parse(l)).size
|
||||
text = "#{year} (#{count})"
|
||||
html << "<li>"
|
||||
html << link_to(text, archive_blog_posts_path(:year => year))
|
||||
html << "</li>"
|
||||
end
|
||||
html << '</ul></nav></section>'
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
def next_or_previous?(post)
|
||||
post.next.present? or post.prev.present?
|
||||
end
|
||||
|
||||
def blog_post_teaser_enabled?
|
||||
BlogPost.teasers_enabled?
|
||||
end
|
||||
|
||||
def blog_post_teaser(post)
|
||||
if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
|
||||
post.custom_teaser.html_safe
|
||||
else
|
||||
truncate(post.body, {
|
||||
:length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
|
||||
:preserve_html_tags => true
|
||||
}).html_safe
|
||||
end
|
||||
end
|
||||
end
|
61
app/helpers/refinery/blog_posts_helper.rb
Normal file
61
app/helpers/refinery/blog_posts_helper.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module Refinery
|
||||
module BlogPostsHelper
|
||||
def blog_archive_list
|
||||
posts = Refinery::BlogPost.select('published_at').all_previous
|
||||
return nil if posts.blank?
|
||||
html = '<section id="blog_archive_list"><h2>'
|
||||
html << t('archives', :scope => 'blog.shared')
|
||||
html << '</h2><nav><ul>'
|
||||
links = []
|
||||
super_old_links = []
|
||||
|
||||
posts.each do |e|
|
||||
if e.published_at >= Time.now.end_of_year.advance(:years => -3)
|
||||
links << e.published_at.strftime('%m/%Y')
|
||||
else
|
||||
super_old_links << e.published_at.strftime('01/%Y')
|
||||
end
|
||||
end
|
||||
links.uniq!
|
||||
super_old_links.uniq!
|
||||
links.each do |l|
|
||||
year = l.split('/')[1]
|
||||
month = l.split('/')[0]
|
||||
count = BlogPost.by_archive(Time.parse(l)).size
|
||||
text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
|
||||
html << "<li>"
|
||||
html << link_to(text, main_app.archive_blog_posts_path(:year => year, :month => month))
|
||||
html << "</li>"
|
||||
end
|
||||
super_old_links.each do |l|
|
||||
year = l.split('/')[1]
|
||||
count = Refinery::BlogPost.by_year(Time.parse(l)).size
|
||||
text = "#{year} (#{count})"
|
||||
html << "<li>"
|
||||
html << link_to(text, main_app.archive_blog_posts_path(:year => year))
|
||||
html << "</li>"
|
||||
end
|
||||
html << '</ul></nav></section>'
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
def next_or_previous?(post)
|
||||
post.next.present? or post.prev.present?
|
||||
end
|
||||
|
||||
def blog_post_teaser_enabled?
|
||||
Refinery::BlogPost.teasers_enabled?
|
||||
end
|
||||
|
||||
def blog_post_teaser(post)
|
||||
if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
|
||||
post.custom_teaser.html_safe
|
||||
else
|
||||
truncate(post.body, {
|
||||
:length => Refinery::Setting.find_or_set(:blog_post_teaser_length, 250),
|
||||
:preserve_html_tags => true
|
||||
}).html_safe
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,8 +3,8 @@
|
|||
<% content_for :body_content_left do %>
|
||||
<% if @blog_posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
|
||||
<%= will_paginate @blog_posts %>
|
||||
<%= render :partial => "/refinery/blog/shared/post", :collection => @blog_posts %>
|
||||
<%= paginate @blog_posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p><%= t('.no_blog_articles_yet') %></p>
|
||||
|
@ -12,11 +12,11 @@
|
|||
<% end %>
|
||||
|
||||
<% content_for :body_content_right do %>
|
||||
<%= render :partial => "/blog/shared/categories" %>
|
||||
<%= render :partial => "/blog/shared/tags" %>
|
||||
<%= render :partial => "/blog/shared/rss_feed" %>
|
||||
<%= render :partial => "/refinery/blog/shared/categories" %>
|
||||
<%= render :partial => "/refinery/blog/shared/tags" %>
|
||||
<%= render :partial => "/refinery/blog/shared/rss_feed" %>
|
||||
<%= blog_archive_list %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<%= render :partial => "/refinery/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<ul id='categories'>
|
||||
<% @blog_categories.each do |category| %>
|
||||
<li<%= " class='selected'" if @category.present? and @category.id == category.id %>>
|
||||
<%= link_to "#{category.title} (#{category.post_count})", blog_category_url(category) %>
|
||||
<%= link_to "#{category.title} (#{category.post_count})", main_app.blog_category_path(category) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% if post.live? %>
|
||||
<article class="blog_post" id="<%= dom_id(post) %>">
|
||||
<header>
|
||||
<h1><%= link_to post.title, blog_post_url(post) %></h1>
|
||||
<h1><%= link_to post.title, main_app.blog_post_path(post) %></h1>
|
||||
<section class='details'>
|
||||
<time datetime="<%=l post.published_at.to_date, :format => :default %>" class='posted_at'>
|
||||
<%= t('created_at', :scope => 'blog.shared.posts', :when => l(post.published_at.to_date, :format => :short)) %>
|
||||
|
@ -10,13 +10,13 @@
|
|||
<% if (categories = post.categories).any? %>
|
||||
<aside class='filed_in'>
|
||||
<%= t('filed_in', :scope => 'blog.posts.show') %>
|
||||
<%=raw categories.collect { |category| link_to category.title, blog_category_url(category) }.to_sentence %>
|
||||
<%=raw categories.collect { |category| link_to category.title, main_app.blog_category_path(category) }.to_sentence %>
|
||||
</aside>
|
||||
<% end %>
|
||||
<% if (tags = post.tags).any? %>
|
||||
<aside class='tagged'>
|
||||
<%= t('tagged', :scope => 'blog.posts.show') %>
|
||||
<%=raw tags.collect { |tag| link_to tag, tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>
|
||||
<%=raw tags.collect { |tag| link_to tag, main_app.tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>
|
||||
</aside>
|
||||
<% end %>
|
||||
</section>
|
||||
|
@ -30,10 +30,10 @@
|
|||
</section>
|
||||
<footer>
|
||||
<p>
|
||||
<%= link_to t('read_more', :scope => 'blog.shared.posts'), blog_post_url(post) if blog_post_teaser_enabled? %>
|
||||
<%= link_to t('read_more', :scope => 'blog.shared.posts'), main_app.blog_post_path(post) if blog_post_teaser_enabled? %>
|
||||
</p>
|
||||
<aside class='comment_count'>
|
||||
<% if BlogPost.comments_allowed? %>
|
||||
<% if Refinery::BlogPost.comments_allowed? %>
|
||||
<% if post.comments.any? %>
|
||||
(<%= pluralize(post.comments.approved.count, t('singular', :scope => 'blog.shared.comments')) %>)
|
||||
<% else %>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<ul id="blog_posts">
|
||||
<% @blog_posts.each do |blog_post| %>
|
||||
<li class='clearfix'>
|
||||
<%= link_to blog_post.title, blog_post_url(blog_post) %>
|
||||
<%= link_to blog_post.title, main_app.blog_post_path(blog_post) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<h2><%= t('.title') %></h2>
|
||||
<%= link_to t('.subscribe'), blog_rss_feed_url, :id => "rss_feed_subscribe"%>
|
||||
<%= link_to t('.subscribe'), main_app.blog_rss_feed_path, :id => "rss_feed_subscribe"%>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<h2><%= t('.title') %></h2>
|
||||
<nav id='tags'>
|
||||
<% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %>
|
||||
<%= link_to tag.name, tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %>
|
||||
<%= link_to tag.name, main_app.tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %>
|
||||
<% end %>
|
||||
</nav>
|
||||
<% end %>
|
|
@ -4,10 +4,10 @@ end
|
|||
|
||||
When /^I visit the tagged posts page for "([^"]*)"$/ do |tag_name|
|
||||
@blog_post ||= Factory.create(:blog_post, :tag_list => tag_name)
|
||||
tag = BlogPost.tag_counts_on(:tags).first
|
||||
tag = ::Refinery::BlogPost.tag_counts_on(:tags).first
|
||||
visit tagged_posts_path(tag.id, tag_name.parameterize)
|
||||
end
|
||||
|
||||
Then /^the blog post should have the tags "([^"]*)"$/ do |tag_list|
|
||||
BlogPost.last.tag_list == tag_list.split(', ')
|
||||
::Refinery::BlogPost.last.tag_list == tag_list.split(', ')
|
||||
end
|
||||
|
|
|
@ -33,7 +33,8 @@ Gem::Specification.new do |s|
|
|||
app/controllers/refinery/blog/posts_controller.rb
|
||||
app/controllers/refinery/blog_controller.rb
|
||||
app/helpers
|
||||
app/helpers/blog_posts_helper.rb
|
||||
app/helpers/refinery
|
||||
app/helpers/refinery/blog_posts_helper.rb
|
||||
app/mailers
|
||||
app/mailers/refinery
|
||||
app/mailers/refinery/blog
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue