File tree Expand file tree Collapse file tree 7 files changed +30
-2
lines changed Expand file tree Collapse file tree 7 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ group :test do
3232 gem 'poltergeist'
3333 gem 'm' , '~> 1.2'
3434
35+ gem 'single_test'
3536 gem 'factory_girl_rails' , '3.3.0'
3637 gem "mocha" , :require => false
3738 gem "sqlite3-ruby" , :require => "sqlite3"
Original file line number Diff line number Diff line change 208208 simple_form (3.0.1 )
209209 actionpack (>= 4.0.0 , < 4.1 )
210210 activemodel (>= 4.0.0 , < 4.1 )
211+ single_test (0.6.0 )
212+ rake
211213 sprockets (2.10.1 )
212214 hike (~> 1.2 )
213215 multi_json (~> 1.0 )
@@ -270,6 +272,7 @@ DEPENDENCIES
270272 quiet_assets
271273 rake
272274 ruby-prof
275+ single_test
273276 sqlite3-ruby
274277 thin
275278 uglifier
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ load 'rails/tasks/engine.rake'
1919Bundler ::GemHelper . install_tasks
2020
2121require 'rake/testtask'
22+ require 'single_test/tasks'
2223
2324Rake ::TestTask . new ( 'units' ) do |t |
2425 t . libs << 'lib'
8081
8182desc 'Runs all the tests, specs and scenarios.'
8283task :test => [ 'project:ensure_db_exists' , 'app:test:prepare' ] do
83- tests_to_run = ENV [ 'TEST' ] ? [ "test:single" ] : %w( test:units spec test:functionals features )
84+ tests_to_run = %w( test:units spec test:functionals features )
8485 run_tests ( tests_to_run )
8586end
8687
Original file line number Diff line number Diff line change @@ -379,6 +379,12 @@ def home?
379379 path == "/"
380380 end
381381
382+
383+ # @return [Boolean] true if this page can be deleted or not.
384+ def deletable?
385+ !home?
386+ end
387+
382388 # This will return the "top level section" for this page, which is the section directly
383389 # below the root (a.k.a My Site) that this page is in. If this page is in root,
384390 # then this will return root.
Original file line number Diff line number Diff line change @@ -80,7 +80,11 @@ def link?
8080 end
8181
8282 def deletable?
83- !self . root? && ( !section? || node . deletable? )
83+ return false if self . root?
84+ if node . respond_to? ( :deletable? )
85+ return node . deletable?
86+ end
87+ true
8488 end
8589
8690 # @param [Section] section
Original file line number Diff line number Diff line change @@ -158,6 +158,12 @@ def setup
158158
159159 class PageTest < ActiveSupport ::TestCase
160160
161+ test "#deletable?" do
162+ @page = build ( :page , path : "/" )
163+ assert @page . home?
164+ refute @page . deletable?
165+ end
166+
161167 def test_creating_page_with_reserved_path
162168 @page = Cms ::Page . new ( :name => "FAIL" , :path => "/cms" )
163169 assert_not_valid @page
Original file line number Diff line number Diff line change @@ -146,6 +146,13 @@ def test_empty_section
146146 assert_decremented section_node_count , Cms ::SectionNode . count
147147 end
148148
149+ test "Homepage should not be #deletable?" do
150+ home = build ( :page )
151+ home . path = "/"
152+
153+ refute home . section_node . deletable? , "Should not be able to delete the homepage as this will cause problems for sites."
154+ end
155+
149156 def test_creating_page_with_reserved_path
150157 @section = Cms ::Section . new ( :name => "FAIL" , :path => "/cms" )
151158 assert_not_valid @section
You can’t perform that action at this time.
0 commit comments