aboutsummaryrefslogtreecommitdiffstats
path: root/spec/requests/refinery/banners
diff options
context:
space:
mode:
authorJames Thompson <james.b.thompson@gmail.com>2012-03-14 11:40:16 +0200
committerJames Thompson <james.b.thompson@gmail.com>2012-03-14 11:40:16 +0200
commit56d7747f54e86993415b76c92e101608e5ea44e2 (patch)
tree025b7b37f50c4c291e7e676286e7767c40adb1f9 /spec/requests/refinery/banners
downloadrefinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.gz
refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.bz2
refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.zip
initial commit
Diffstat (limited to 'spec/requests/refinery/banners')
-rw-r--r--spec/requests/refinery/banners/admin/banners_spec.rb101
1 files changed, 101 insertions, 0 deletions
diff --git a/spec/requests/refinery/banners/admin/banners_spec.rb b/spec/requests/refinery/banners/admin/banners_spec.rb
new file mode 100644
index 0000000..2ffb5bd
--- /dev/null
+++ b/spec/requests/refinery/banners/admin/banners_spec.rb
@@ -0,0 +1,101 @@
+# encoding: utf-8
+require "spec_helper"
+
+describe Refinery do
+ describe "Banners" do
+ describe "Admin" do
+ describe "banners" do
+ login_refinery_user
+
+ describe "banners list" do
+ before(:each) do
+ FactoryGirl.create(:banner, :name => "UniqueTitleOne")
+ FactoryGirl.create(:banner, :name => "UniqueTitleTwo")
+ end
+
+ it "shows two items" do
+ visit refinery.banners_admin_banners_path
+ page.should have_content("UniqueTitleOne")
+ page.should have_content("UniqueTitleTwo")
+ end
+ end
+
+ describe "create" do
+ before(:each) do
+ visit refinery.banners_admin_banners_path
+
+ click_link "Add New Banner"
+ end
+
+ context "valid data" do
+ it "should succeed" do
+ fill_in "Name", :with => "This is a test of the first string field"
+ click_button "Save"
+
+ page.should have_content("'This is a test of the first string field' was successfully added.")
+ Refinery::Banners::Banner.count.should == 1
+ end
+ end
+
+ context "invalid data" do
+ it "should fail" do
+ click_button "Save"
+
+ page.should have_content("Name can't be blank")
+ Refinery::Banners::Banner.count.should == 0
+ end
+ end
+
+ context "duplicate" do
+ before(:each) { FactoryGirl.create(:banner, :name => "UniqueTitle") }
+
+ it "should fail" do
+ visit refinery.banners_admin_banners_path
+
+ click_link "Add New Banner"
+
+ fill_in "Name", :with => "UniqueTitle"
+ click_button "Save"
+
+ page.should have_content("There were problems")
+ Refinery::Banners::Banner.count.should == 1
+ end
+ end
+
+ end
+
+ describe "edit" do
+ before(:each) { FactoryGirl.create(:banner, :name => "A name") }
+
+ it "should succeed" do
+ visit refinery.banners_admin_banners_path
+
+ within ".actions" do
+ click_link "Edit this banner"
+ end
+
+ fill_in "Name", :with => "A different name"
+ click_button "Save"
+
+ page.should have_content("'A different name' was successfully updated.")
+ page.should have_no_content("A name")
+ end
+ end
+
+ describe "destroy" do
+ before(:each) { FactoryGirl.create(:banner, :name => "UniqueTitleOne") }
+
+ it "should succeed" do
+ visit refinery.banners_admin_banners_path
+
+ click_link "Remove this banner forever"
+
+ page.should have_content("'UniqueTitleOne' was successfully removed.")
+ Refinery::Banners::Banner.count.should == 0
+ end
+ end
+
+ end
+ end
+ end
+end