diff options
Diffstat (limited to 'vendor/extensions/gallery_links/spec')
4 files changed, 157 insertions, 0 deletions
diff --git a/vendor/extensions/gallery_links/spec/features/refinery/gallery_links/admin/gallery_links_spec.rb b/vendor/extensions/gallery_links/spec/features/refinery/gallery_links/admin/gallery_links_spec.rb new file mode 100644 index 0000000..f49e600 --- /dev/null +++ b/vendor/extensions/gallery_links/spec/features/refinery/gallery_links/admin/gallery_links_spec.rb @@ -0,0 +1,101 @@ +# encoding: utf-8 +require "spec_helper" + +describe Refinery do + describe "GalleryLinks" do + describe "Admin" do + describe "gallery_links" do + refinery_login_with :refinery_user + + describe "gallery_links list" do + before do + FactoryGirl.create(:gallery_link, :title => "UniqueTitleOne") + FactoryGirl.create(:gallery_link, :title => "UniqueTitleTwo") + end + + it "shows two items" do + visit refinery.gallery_links_admin_gallery_links_path + page.should have_content("UniqueTitleOne") + page.should have_content("UniqueTitleTwo") + end + end + + describe "create" do + before do + visit refinery.gallery_links_admin_gallery_links_path + + click_link "Add New Gallery Link" + end + + context "valid data" do + it "should succeed" do + fill_in "Title", :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::GalleryLinks::GalleryLink.count.should == 1 + end + end + + context "invalid data" do + it "should fail" do + click_button "Save" + + page.should have_content("Title can't be blank") + Refinery::GalleryLinks::GalleryLink.count.should == 0 + end + end + + context "duplicate" do + before { FactoryGirl.create(:gallery_link, :title => "UniqueTitle") } + + it "should fail" do + visit refinery.gallery_links_admin_gallery_links_path + + click_link "Add New Gallery Link" + + fill_in "Title", :with => "UniqueTitle" + click_button "Save" + + page.should have_content("There were problems") + Refinery::GalleryLinks::GalleryLink.count.should == 1 + end + end + + end + + describe "edit" do + before { FactoryGirl.create(:gallery_link, :title => "A title") } + + it "should succeed" do + visit refinery.gallery_links_admin_gallery_links_path + + within ".actions" do + click_link "Edit this gallery link" + end + + fill_in "Title", :with => "A different title" + click_button "Save" + + page.should have_content("'A different title' was successfully updated.") + page.should have_no_content("A title") + end + end + + describe "destroy" do + before { FactoryGirl.create(:gallery_link, :title => "UniqueTitleOne") } + + it "should succeed" do + visit refinery.gallery_links_admin_gallery_links_path + + click_link "Remove this gallery link forever" + + page.should have_content("'UniqueTitleOne' was successfully removed.") + Refinery::GalleryLinks::GalleryLink.count.should == 0 + end + end + + end + end + end +end diff --git a/vendor/extensions/gallery_links/spec/models/refinery/gallery_links/gallery_link_spec.rb b/vendor/extensions/gallery_links/spec/models/refinery/gallery_links/gallery_link_spec.rb new file mode 100644 index 0000000..d7e9e13 --- /dev/null +++ b/vendor/extensions/gallery_links/spec/models/refinery/gallery_links/gallery_link_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +module Refinery + module GalleryLinks + describe GalleryLink do + describe "validations" do + subject do + FactoryGirl.create(:gallery_link, + :title => "Refinery CMS") + end + + it { should be_valid } + its(:errors) { should be_empty } + its(:title) { should == "Refinery CMS" } + end + end + end +end diff --git a/vendor/extensions/gallery_links/spec/spec_helper.rb b/vendor/extensions/gallery_links/spec/spec_helper.rb new file mode 100644 index 0000000..d3214e2 --- /dev/null +++ b/vendor/extensions/gallery_links/spec/spec_helper.rb @@ -0,0 +1,31 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] ||= 'test' + +if File.exist?(dummy_path = File.expand_path('../dummy/config/environment.rb', __FILE__)) + require dummy_path +elsif File.dirname(__FILE__) =~ %r{vendor/extensions} + # Require the path to the refinerycms application this is vendored inside. + require File.expand_path('../../../../../config/environment', __FILE__) +else + puts "Could not find a config/environment.rb file to require. Please specify this in #{File.expand_path(__FILE__)}" +end + +require 'rspec/rails' +require 'capybara/rspec' + +Rails.backtrace_cleaner.remove_silencers! + +RSpec.configure do |config| + config.mock_with :rspec + config.treat_symbols_as_metadata_keys_with_true_values = true + config.filter_run :focus => true + config.run_all_when_everything_filtered = true +end + +# Requires supporting files with custom matchers and macros, etc, +# in ./support/ and its subdirectories including factories. +([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p| + Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s] +}.flatten.sort.each do |support_file| + require support_file +end diff --git a/vendor/extensions/gallery_links/spec/support/factories/refinery/gallery_links.rb b/vendor/extensions/gallery_links/spec/support/factories/refinery/gallery_links.rb new file mode 100644 index 0000000..8b84ed2 --- /dev/null +++ b/vendor/extensions/gallery_links/spec/support/factories/refinery/gallery_links.rb @@ -0,0 +1,7 @@ + +FactoryGirl.define do + factory :gallery_link, :class => Refinery::GalleryLinks::GalleryLink do + sequence(:title) { |n| "refinery#{n}" } + end +end + |