diff options
author | Pete Higgins <pete@peterhiggins.org> | 2012-01-08 13:52:44 -0800 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2012-01-08 13:52:44 -0800 |
commit | 63b0bec5ff625738ce0072f41fd05439dcd08d0e (patch) | |
tree | 0d2560b857aede1836a8f437a0d89d03730694ac | |
parent | e3e5bcffc3f7ddb744054feee0d7934e4cdc053e (diff) | |
download | refinerycms-blog-63b0bec5ff625738ce0072f41fd05439dcd08d0e.tar.gz refinerycms-blog-63b0bec5ff625738ce0072f41fd05439dcd08d0e.tar.bz2 refinerycms-blog-63b0bec5ff625738ce0072f41fd05439dcd08d0e.zip |
Make DB seed idempotent.
-rw-r--r-- | db/seeds.rb | 2 | ||||
-rw-r--r-- | spec/lib/refinery/blog/engine_spec.rb | 19 |
2 files changed, 16 insertions, 5 deletions
diff --git a/db/seeds.rb b/db/seeds.rb index bd273ea..d603553 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,7 +5,7 @@ Refinery::User.find(:all).each do |user| end end if defined?(Refinery::User) -if defined?(Refinery::Page) +if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => '/blog') page = Refinery::Page.create( :title => "Blog", :link_url => "/blog", diff --git a/spec/lib/refinery/blog/engine_spec.rb b/spec/lib/refinery/blog/engine_spec.rb index 5b36fd8..1c44da7 100644 --- a/spec/lib/refinery/blog/engine_spec.rb +++ b/spec/lib/refinery/blog/engine_spec.rb @@ -3,12 +3,23 @@ require 'spec_helper' module Refinery module Blog describe Engine do - let(:activity) do - Refinery::Plugins.registered.find_by_name("refinerycms_blog").activity.first + describe "plugin activity" do + let(:activity) do + Refinery::Plugins.registered.find_by_name("refinerycms_blog").activity.first + end + + it "sets the correct path for activity entries" do + activity.url.should eq("edit_refinery_admin_blog_posts_path") + end end - it "sets the correct path for activity entries" do - activity.url.should eq("edit_refinery_admin_blog_posts_path") + describe ".load_seed" do + it "is idempotent" do + Refinery::Blog::Engine.load_seed + Refinery::Blog::Engine.load_seed + + Refinery::Page.where(:link_url => '/blog').count.should eq(1) + end end end end |