diff options
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | Gemfile | 30 | ||||
-rw-r--r-- | Rakefile | 2 | ||||
-rw-r--r-- | app/assets/javascripts/refinery/blog/backend.js | 73 | ||||
-rw-r--r-- | app/controllers/refinery/blog/categories_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/refinery/blog/posts_controller.rb | 14 | ||||
-rw-r--r-- | app/helpers/refinery/blog/controller_helper.rb | 10 | ||||
-rw-r--r-- | app/models/refinery/blog/comment.rb | 28 | ||||
-rw-r--r-- | app/models/refinery/blog/post.rb | 49 | ||||
-rw-r--r-- | app/views/refinery/blog/admin/posts/_form.html.erb | 2 | ||||
-rw-r--r-- | app/views/refinery/shared/admin/_autocomplete.html.erb | 45 | ||||
-rw-r--r-- | changelog.md | 5 | ||||
-rw-r--r-- | config/routes.rb | 6 | ||||
-rw-r--r-- | db/migrate/20110803223522_create_blog_structure.rb | 8 | ||||
-rw-r--r-- | refinerycms-blog.gemspec | 11 | ||||
-rwxr-xr-x | script/rails | 4 | ||||
-rw-r--r-- | spec/features/refinery/blog/admin/posts_spec.rb | 17 | ||||
-rw-r--r-- | spec/models/refinery/blog/category_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/refinery/blog/post_spec.rb | 8 |
19 files changed, 167 insertions, 154 deletions
diff --git a/.travis.yml b/.travis.yml index 56586f2..54c0145 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,3 @@ matrix: - rvm: rbx-19mode rvm: - 2.0.0 - - 1.9.3 - - rbx-19mode - - jruby-19mode @@ -2,11 +2,18 @@ source "https://rubygems.org" gemspec -gem 'refinerycms', '~> 2.1.0' -gem 'refinerycms-testing', :github => 'refinery/refinerycms', :branch => '2-1-stable', :group => :test -gem 'refinerycms-settings', '~> 2.1.0' -gem 'refinerycms-acts-as-indexed', :github => 'refinery/refinerycms-acts-as-indexed', :branch => '1-0-stable' - +git 'https://github.com/refinery/refinerycms.git', branch: 'rails4' do + gem 'refinerycms-authentication' + gem 'refinerycms-dashboard' + gem 'refinerycms-pages' + gem 'refinerycms-testing', group: :test +end +gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n', branch: 'master' +gem 'refinerycms-settings', github: 'refinery/refinerycms-settings', branch: 'master' +gem 'refinerycms-acts-as-indexed', github: 'refinery/refinerycms-acts-as-indexed', branch: 'master' +gem 'protected_attributes' +gem 'globalize3', github: 'svenfuchs/globalize3', branch: 'rails4' +gem 'seo_meta', github: 'parndt/seo_meta', branch: 'master' # Database Configuration unless ENV['TRAVIS'] @@ -25,13 +32,12 @@ if !ENV['TRAVIS'] || ENV['DB'] == 'postgresql' gem 'pg', :platform => :ruby end -gem 'jruby-openssl', :platform => :jruby - -# Refinery/rails should pull in the proper versions of these -group :assets do - gem 'sass-rails' - gem 'coffee-rails' - gem 'uglifier' +group :test do + gem 'launchy' +end +group :development, :test do + gem 'pry' + gem 'pry-nav' end # Load local gems according to Refinery developer preference. @@ -13,7 +13,7 @@ if File.exists?(APP_RAKEFILE) end require "refinerycms-testing" -Refinery::Testing::Railtie.load_tasks +# Refinery::Testing::Railtie.load_tasks Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH) load File.expand_path('../tasks/rspec.rake', __FILE__) diff --git a/app/assets/javascripts/refinery/blog/backend.js b/app/assets/javascripts/refinery/blog/backend.js index 77529c5..d4869c1 100644 --- a/app/assets/javascripts/refinery/blog/backend.js +++ b/app/assets/javascripts/refinery/blog/backend.js @@ -48,68 +48,23 @@ $(document).ready(function(){ e.preventDefault(); }); - - $(function() { - $('#page-tabs').tabs(); - $('#copy_body_link').click(function(event) { - // Find the WYMEditor that maps to the custom_teaser field - var teaserTextArea = $('#post_custom_teaser')[0]; - var teaserEditor = null; - $.each(WYMeditor.INSTANCES, function(index, editor) { - if (editor._element[0] == teaserTextArea) { - teaserEditor = editor; - } - }); - - if (teaserEditor) { - teaserEditor.html($('#post_body').attr('value')); + $('#page-tabs').tabs(); + $('#copy_body_link').click(function(event) { + // Find the WYMEditor that maps to the custom_teaser field + var teaserTextArea = $('#post_custom_teaser')[0]; + var teaserEditor = null; + $.each(WYMeditor.INSTANCES, function(index, editor) { + if (editor._element[0] == teaserTextArea) { + teaserEditor = editor; } - - event.preventDefault(); }); - }); - - function split( val ) { - return val.split( /,\s*/ ); - } - function extractLast( term ) { - return split( term ).pop(); - } + if (teaserEditor) { + teaserEditor.html($('#post_body').attr('value')); + } - page_options.init(false, '', '') + event.preventDefault(); + }); - $('<%= dom_id %>').bind( "keydown", function( event ) { - if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) { - event.preventDefault() - } - }).autocomplete({ - source: function( request, response ) { - $.getJSON( "<%= url %>", { - term: extractLast( request.term ) - }, response ); - }, - search: function() { - // custom minLength - var term = extractLast( this.value ); - if ( term.length < 2 ) { - return false; - } - }, - focus: function() { - // prevent value inserted on focus - return false; - }, - select: function( event, ui ) { - var terms = split( this.value ); - // remove the current input - terms.pop(); - // add the selected item - terms.push( ui.item.value ); - // add placeholder to get the comma-and-space at the end - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }) + page_options.init(false, '', ''); }); diff --git a/app/controllers/refinery/blog/categories_controller.rb b/app/controllers/refinery/blog/categories_controller.rb index 23a835a..b5ab574 100644 --- a/app/controllers/refinery/blog/categories_controller.rb +++ b/app/controllers/refinery/blog/categories_controller.rb @@ -3,7 +3,7 @@ module Refinery class CategoriesController < BlogController def show - @category = Refinery::Blog::Category.find(params[:id]) + @category = Refinery::Blog::Category.friendly.find(params[:id]) @posts = @category.posts.live.includes(:comments, :categories).with_globalize.page(params[:page]) end diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb index 05cd2d6..20ac12b 100644 --- a/app/controllers/refinery/blog/posts_controller.rb +++ b/app/controllers/refinery/blog/posts_controller.rb @@ -2,7 +2,7 @@ module Refinery module Blog class PostsController < BlogController - before_filter :find_all_blog_posts, :except => [:archive] + before_filter :paginate_all_blog_posts, :except => [:archive] before_filter :find_blog_post, :only => [:show, :comment, :update_nav] before_filter :find_tags @@ -10,9 +10,12 @@ module Refinery def index if request.format.rss? - @posts = Post.live.includes(:comments, :categories) - # limit rss feed for services (like feedburner) who have max size - @posts = Post.recent(params["max_results"]) if params["max_results"].present? + @posts = if params["max_results"].present? + # limit rss feed for services (like feedburner) who have max size + Post.recent(params["max_results"]) + else + Post.newest_first.live.includes(:comments, :categories) + end end respond_with (@posts) do |format| format.html @@ -34,7 +37,8 @@ module Refinery end def comment - if (@comment = @post.comments.create(params[:comment])).valid? + @comment = @post.comments.create(params[:comment]) + if @comment.valid? if Comment::Moderation.enabled? or @comment.ham? begin CommentMailer.notification(@comment, request).deliver diff --git a/app/helpers/refinery/blog/controller_helper.rb b/app/helpers/refinery/blog/controller_helper.rb index edbf934..4bec046 100644 --- a/app/helpers/refinery/blog/controller_helper.rb +++ b/app/helpers/refinery/blog/controller_helper.rb @@ -5,9 +5,10 @@ module Refinery protected def find_blog_post - unless (@post = Refinery::Blog::Post.with_globalize.find(params[:id])).try(:live?) - if refinery_user? and current_refinery_user.authorized_plugins.include?("refinerycms_blog") - @post = Refinery::Blog::Post.find(params[:id]) + @post = all_blog_posts.friendly.find(params[:id]) + unless @post.try(:live?) + if refinery_user? && current_refinery_user.authorized_plugins.include?("refinerycms_blog") + @post = Post.friendly.find(params[:id]) else error_404 end @@ -15,12 +16,13 @@ module Refinery end def find_all_blog_posts - @posts = Refinery::Blog::Post.live.includes(:comments, :categories).with_globalize.page(params[:page]) + @posts = all_blog_posts.live end def find_tags @tags = Refinery::Blog::Post.live.tag_counts_on(:tags) end + def find_all_blog_categories @categories = Refinery::Blog::Category.translated end diff --git a/app/models/refinery/blog/comment.rb b/app/models/refinery/blog/comment.rb index 7661e81..ae35a59 100644 --- a/app/models/refinery/blog/comment.rb +++ b/app/models/refinery/blog/comment.rb @@ -4,28 +4,26 @@ module Refinery attr_accessible :name, :email, :message - filters_spam :author_field => :name, - :email_field => :email, - :message_field => :body + filters_spam author_field: :name, email_field: :email, message_field: :body - belongs_to :post, :foreign_key => 'blog_post_id' + belongs_to :post, foreign_key: 'blog_post_id' alias_attribute :message, :body - validates :name, :message, :presence => true - validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i } + validates :name, :message, presence: true + validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i } class << self def unmoderated - where(:state => nil) + where(state: nil) end def approved - where(:state => 'approved') + where(state: 'approved') end def rejected - where(:state => 'rejected') + where(state: 'rejected') end end @@ -55,7 +53,7 @@ module Refinery currently = Refinery::Setting.find_or_set(:comments_allowed, true, { :scoping => 'blog' }) - Refinery::Setting.set(:comments_allowed, {:value => !currently, :scoping => 'blog'}) + Refinery::Setting.set(:comments_allowed, {value: !currently, scoping: 'blog'}) end before_create do |comment| @@ -68,16 +66,16 @@ module Refinery class << self def enabled? Refinery::Setting.find_or_set(:comment_moderation, true, { - :scoping => 'blog', - :restricted => false + scoping: 'blog', + restricted: false }) end def toggle! new_value = { - :value => !Blog::Comment::Moderation.enabled?, - :scoping => 'blog', - :restricted => false + value: !Blog::Comment::Moderation.enabled?, + scoping: 'blog', + restricted: false } Refinery::Setting.set(:comment_moderation, new_value) end diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb index cf0a526..1c2cf04 100644 --- a/app/models/refinery/blog/post.rb +++ b/app/models/refinery/blog/post.rb @@ -12,9 +12,7 @@ module Refinery is_seo_meta if self.table_exists? - default_scope :order => 'published_at DESC' - - belongs_to :author, :class_name => Refinery::Blog.user_class.to_s, :foreign_key => :user_id, :readonly => true + belongs_to :author, proc{ readonly(true) }, :class_name => Refinery::Blog.user_class.to_s, :foreign_key => :user_id has_many :comments, :dependent => :destroy, :foreign_key => :blog_post_id acts_as_taggable @@ -37,11 +35,10 @@ module Refinery attr_accessible :source_url, :source_url_title attr_accessor :locale - - class Translation - is_seo_meta - attr_accessible :browser_title, :meta_description, :locale - end + class Translation + is_seo_meta + attr_accessible :browser_title, :meta_description, :locale + end # Delegate SEO Attributes to globalize3 translation seo_fields = ::SeoMeta.attributes.keys.map{|a| [a, :"#{a}="]}.flatten @@ -63,7 +60,7 @@ module Refinery end def live? - !draft and published_at <= Time.now + !draft && published_at <= Time.now end def friendly_id_source @@ -82,7 +79,8 @@ module Refinery end end # A join implies readonly which we don't really want. - joins(:translations).where(globalized_conditions).where(conditions).readonly(false) + where(conditions).joins(:translations).where(globalized_conditions) + .readonly(false) end def find_by_slug_or_id(slug_or_id) @@ -94,44 +92,49 @@ module Refinery end def by_month(date) - where(:published_at => date.beginning_of_month..date.end_of_month) + newest_first.where(:published_at => date.beginning_of_month..date.end_of_month) end - def by_archive(date) - Refinery.deprecate("Refinery::Blog::Post.by_archive(date)", {:replacement => "Refinery::Blog::Post.by_month(date)", :when => 2.2 }) - by_month(date) + def by_year(date) + newest_first.where(:published_at => date.beginning_of_year..date.end_of_year).with_globalize end - def by_year(date) - where(:published_at => date.beginning_of_year..date.end_of_year).with_globalize + def newest_first + order("published_at DESC") end def published_dates_older_than(date) - published_before(date).select(:published_at).map(&:published_at) + newest_first.published_before(date).select(:published_at).map(&:published_at) end def recent(count) - live.limit(count) + newest_first.live.limit(count) end def popular(count) - unscoped.order("access_count DESC").limit(count).with_globalize + order("access_count DESC").limit(count).with_globalize end def previous(item) - published_before(item.published_at).first + newest_first.published_before(item.published_at).first end def uncategorized - live.includes(:categories).where(Refinery::Blog::Categorization.table_name => { :blog_category_id => nil }) + newest_first.live.includes(:categories).where( + Refinery::Blog::Categorization.table_name => { :blog_category_id => nil } + ) end def next(current_record) - where(["published_at > ? and draft = ?", current_record.published_at, false]).reorder('published_at ASC').with_globalize.first + where(arel_table[:published_at].gt(current_record.published_at)) + .where(:draft => false) + .order('published_at ASC').with_globalize.first end def published_before(date=Time.now) - where("published_at < ? and draft = ?", date, false).with_globalize + where(arel_table[:published_at].lt(date)) + .where(:draft => false) + .with_globalize end alias_method :live, :published_before diff --git a/app/views/refinery/blog/admin/posts/_form.html.erb b/app/views/refinery/blog/admin/posts/_form.html.erb index f9666ba..b2a31e1 100644 --- a/app/views/refinery/blog/admin/posts/_form.html.erb +++ b/app/views/refinery/blog/admin/posts/_form.html.erb @@ -112,5 +112,5 @@ <% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %> <% content_for :javascripts, javascript_include_tag('refinery/blog/backend') %> <%= render 'refinery/shared/admin/autocomplete', - :dom_id => '#blog_post_tag_list', + :dom_id => '#post_tag_list', :url => refinery.tags_blog_admin_posts_url %> diff --git a/app/views/refinery/shared/admin/_autocomplete.html.erb b/app/views/refinery/shared/admin/_autocomplete.html.erb index 97d4ac8..1131f89 100644 --- a/app/views/refinery/shared/admin/_autocomplete.html.erb +++ b/app/views/refinery/shared/admin/_autocomplete.html.erb @@ -1 +1,46 @@ <% content_for :stylesheets, stylesheet_link_tag("refinery/blog/ui-lightness/jquery-ui-1.8.13.custom") %> +<% content_for :javascripts do %> +<script> + function split(val) { + return val.split(/,\s*/); + } + function extractLast(term) { + return split(term).pop(); + } + $(document).ready(function(){ + $('<%= dom_id %>').bind("keydown", function(event) { + if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active) { + event.preventDefault() + } + }).autocomplete({ + source: function(request, response) { + $.getJSON("<%= url %>", { + term: extractLast(request.term) + }, response); + }, + search: function() { + // custom minLength + var term = extractLast(this.value); + if (term.length < 2) { + return false; + } + }, + focus: function() { + // prevent value inserted on focus + return false; + }, + select: function(event, ui) { + var terms = split(this.value); + // remove the current input + terms.pop(); + // add the selected item + terms.push(ui.item.value); + // add placeholder to get the comma-and-space at the end + terms.push(""); + this.value = terms.join(", "); + return false; + } + }); + }) +</script> +<% end %> diff --git a/changelog.md b/changelog.md index e6415e6..9a7b32e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## 3.0.0 [UNRELEASED] +* Removed `Post#default_scope` in favour of opting in to `Post#newest_first`. [parndt](https://github.com/parndt) + ## 1.6.3 [UNRELEASED] * Bulgarian translations [mirosr](https://github.com/mirosr) * posts/tagged... params[:tag_name] is optional [joemsak](https://github.com/joemsak) @@ -66,4 +69,4 @@ * Rails 3 Support * Archives * Categories -* [See full list](https://github.com/resolve/refinerycms-blog/compare/1.0...1.1)
\ No newline at end of file +* [See full list](https://github.com/resolve/refinerycms-blog/compare/1.0...1.1) diff --git a/config/routes.rb b/config/routes.rb index ad4db70..8a7ae27 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,9 +3,9 @@ Refinery::Core::Engine.routes.draw do root :to => "posts#index" resources :posts, :only => [:show] - match 'feed.rss', :to => 'posts#index', :as => 'rss_feed', :defaults => {:format => "rss"} - match 'categories/:id', :to => 'categories#show', :as => 'category' - match ':id/comments', :to => 'posts#comment', :as => 'comments' + get 'feed.rss', :to => 'posts#index', :as => 'rss_feed', :defaults => {:format => "rss"} + get 'categories/:id', :to => 'categories#show', :as => 'category' + post ':id/comments', :to => 'posts#comment', :as => 'comments' get 'archive/:year(/:month)', :to => 'posts#archive', :as => 'archive_posts' get 'tagged/:tag_id(/:tag_name)' => 'posts#tagged', :as => 'tagged_posts' end diff --git a/db/migrate/20110803223522_create_blog_structure.rb b/db/migrate/20110803223522_create_blog_structure.rb index 37f4bd7..43488f9 100644 --- a/db/migrate/20110803223522_create_blog_structure.rb +++ b/db/migrate/20110803223522_create_blog_structure.rb @@ -1,7 +1,7 @@ class CreateBlogStructure < ActiveRecord::Migration def up - create_table :refinery_blog_posts, :id => true do |t| + create_table :refinery_blog_posts do |t| t.string :title t.text :body t.boolean :draft @@ -11,7 +11,7 @@ class CreateBlogStructure < ActiveRecord::Migration add_index :refinery_blog_posts, :id - create_table :refinery_blog_comments, :id => true do |t| + create_table :refinery_blog_comments do |t| t.integer :blog_post_id t.boolean :spam t.string :name @@ -24,14 +24,14 @@ class CreateBlogStructure < ActiveRecord::Migration add_index :refinery_blog_comments, :id add_index :refinery_blog_comments, :blog_post_id - create_table :refinery_blog_categories, :id => true do |t| + create_table :refinery_blog_categories do |t| t.string :title t.timestamps end add_index :refinery_blog_categories, :id - create_table :refinery_blog_categories_blog_posts, :id => true do |t| + create_table :refinery_blog_categories_blog_posts do |t| t.integer :blog_category_id t.integer :blog_post_id end diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec index 907bbcd..f111719 100644 --- a/refinerycms-blog.gemspec +++ b/refinerycms-blog.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = %q{refinerycms-blog} - s.version = %q{2.1.0} + s.version = %q{3.0.0.dev} s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with Refinery CMS.} s.summary = %q{Ruby on Rails blogging engine for Refinery CMS.} s.email = %q{info@refinerycms.com} @@ -15,11 +15,12 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -- spec/*`.split("\n") # Runtime dependencies - s.add_dependency 'refinerycms-core', '~> 2.1.0' - s.add_dependency 'refinerycms-settings', '~> 2.1.0' + s.add_dependency 'refinerycms-core', '~> 3.0.0.dev' + s.add_dependency 'refinerycms-settings', '~> 3.0.0.dev' s.add_dependency 'filters_spam', '~> 0.2' s.add_dependency 'acts-as-taggable-on' s.add_dependency 'seo_meta', '~> 1.4.0' - s.add_dependency 'rails_autolink', '~> 1.0.7' - s.add_dependency 'friendly_id', '~> 4.0.4' + s.add_dependency 'rails_autolink', '~> 1.1.3' + s.add_dependency 'friendly_id', '~> 5.0.0.rc1' + s.add_dependency 'globalize3', '~> 0.3.0' end diff --git a/script/rails b/script/rails index 4309856..6315b3e 100755 --- a/script/rails +++ b/script/rails @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -#!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. ENGINE_PATH = File.expand_path('../..', __FILE__) -load File.expand_path('../../spec/dummy/script/rails', __FILE__) +load File.expand_path('../../spec/dummy/bin/rails', __FILE__) diff --git a/spec/features/refinery/blog/admin/posts_spec.rb b/spec/features/refinery/blog/admin/posts_spec.rb index a5d4f62..5dca929 100644 --- a/spec/features/refinery/blog/admin/posts_spec.rb +++ b/spec/features/refinery/blog/admin/posts_spec.rb @@ -39,16 +39,18 @@ module Refinery describe "create blog post", :js => true do before do + subject.class.count.should eq(0) fill_in "post_title", :with => "This is my blog post" + # this is a dirty hack but textarea that needs to be filled is # hidden and capybara refuses to fill in elements it can't see page.evaluate_script("WYMeditor.INSTANCES[0].html('<p>And I love it</p>')") click_link "toggle_advanced_options" + page.should have_css '.blog_categories' + page.should have_css "#post_category_ids_#{blog_category.id}" check blog_category.title + find_field("post_category_ids_#{blog_category.id}").should be_checked click_button "Save" - end - - it "should succeed" do page.should have_content("was successfully added.") end @@ -67,13 +69,13 @@ module Refinery end describe "create blog post with tags", :js => true do + let(:tag_list) { "chicago, bikes, beers, babes" } before do - @tag_list = "chicago, bikes, beers, babes" fill_in "Title", :with => "This is a tagged blog post" # this is a dirty hack but textarea that needs to be filled is # hidden and capybara refuses to fill in elements it can't see page.evaluate_script("WYMeditor.INSTANCES[0].html('<p>And I also love it</p>')") - fill_in "Tags", :with => @tag_list + fill_in "Tags", :with => tag_list click_button "Save" end @@ -86,7 +88,7 @@ module Refinery end it "should have the specified tags" do - subject.class.last.tag_list.sort.should eq(@tag_list.split(', ').sort) + subject.class.last.tag_list.sort.should eq(tag_list.split(', ').sort) end end end @@ -171,9 +173,6 @@ module Refinery select other_guy.username, :from => "Author" click_button "Save" - end - - it "should succeed" do page.should have_content("was successfully added.") end diff --git a/spec/models/refinery/blog/category_spec.rb b/spec/models/refinery/blog/category_spec.rb index ad83017..9cd5d97 100644 --- a/spec/models/refinery/blog/category_spec.rb +++ b/spec/models/refinery/blog/category_spec.rb @@ -32,7 +32,7 @@ module Refinery :published_at => Time.now, :author => refinery_user }) - category.posts.first.should == latest_post + category.posts.newest_first.first.should == latest_post end end @@ -47,4 +47,4 @@ module Refinery end end end -end
\ No newline at end of file +end diff --git a/spec/models/refinery/blog/post_spec.rb b/spec/models/refinery/blog/post_spec.rb index bc9de6e..8b156cb 100644 --- a/spec/models/refinery/blog/post_spec.rb +++ b/spec/models/refinery/blog/post_spec.rb @@ -95,8 +95,10 @@ module Refinery end it "returns all posts which aren't in draft and pub date isn't in future" do - described_class.live.count.should be == 2 - described_class.live.should == [@post2, @post1] + live_posts = described_class.live + live_posts.count.should be == 2 + live_posts.should include(@post2) + live_posts.should include(@post1) end end @@ -135,7 +137,7 @@ module Refinery end it "returns next article when called on current article" do - described_class.last.next.should == @post + described_class.newest_first.last.next.should == @post end end |