File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
module Schked
6
6
class Config
7
- attr_writer :logger
7
+ attr_writer :logger ,
8
+ :do_not_load_root_schedule
8
9
9
10
def paths
10
11
@paths ||= [ ]
@@ -18,6 +19,10 @@ def logger
18
19
@logger ||= Logger . new ( $stdout) . tap { |l | l . level = Logger ::INFO }
19
20
end
20
21
22
+ def do_not_load_root_schedule?
23
+ !!@do_not_load_root_schedule
24
+ end
25
+
21
26
def register_callback ( name , &block )
22
27
callbacks [ name ] << block
23
28
end
Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ module Schked
6
6
class Railtie < Rails ::Railtie
7
7
class PathsConfig
8
8
def self . call ( app )
9
- if ( root_schedule = app . root . join ( "config" , "schedule.rb" ) ) . exist?
9
+ return if Schked . config . do_not_load_root_schedule?
10
+
11
+ root_schedule = app . root . join ( "config" , "schedule.rb" )
12
+ if root_schedule . exist?
10
13
path = root_schedule . to_s
11
14
Schked . config . paths << path unless Schked . config . paths . include? ( path )
12
15
end
Original file line number Diff line number Diff line change 4
4
5
5
describe Schked ::Railtie do
6
6
describe "schked.config" do
7
- subject ( :config ) { Schked . config }
7
+ let ( :config ) { Schked ::Config . new }
8
+
9
+ before do
10
+ allow ( Schked ) . to receive ( :config ) . and_return ( config )
11
+ end
8
12
9
13
context "when by default root schedule doesn't exist" do
10
14
it { expect ( config . paths ) . to be_empty }
36
40
expect ( config . paths ) . to match_array ( [ schedule_path ] )
37
41
end
38
42
end
43
+
44
+ context "when passed do_not_load_root_schedule config option" do
45
+ before { config . do_not_load_root_schedule = true }
46
+
47
+ it "doesn't add root schedule to paths" do
48
+ expect ( config . paths ) . to be_empty
49
+ end
50
+ end
39
51
end
40
52
end
41
53
end
You can’t perform that action at this time.
0 commit comments