# HG changeset patch # User Michael Granger # Date 1210282338 0 # Node ID 9b9e85ccf4f979744971e23441441f4746b9b043 # Parent 7b5a0131d5cdbc73548e90987840e7529b73bee1 Add a test for a customized moderator's directory in the dir/remote file. (with Michael) diff -r 7b5a0131d5cd -r 9b9e85ccf4f9 spec/ezmlm/list_spec.rb --- a/spec/ezmlm/list_spec.rb Thu May 08 21:12:48 2008 +0000 +++ b/spec/ezmlm/list_spec.rb Thu May 08 21:32:18 2008 +0000 @@ -189,6 +189,38 @@ mods.should include( *TEST_MODERATORS ) end + it "can get a list of modererators when remote subscription moderation is enabled" + + " and the modsub configuration is empty" do + # Test the moderation config files for existence + modsub_path_obj = mock( "Mock 'modsub' path object" ) + @listpath.should_receive( :+ ).with( 'modsub' ).twice.and_return( modsub_path_obj ) + modsub_path_obj.should_receive( :exist? ).twice.and_return( false ) + remote_path_obj = mock( "Mock 'remote' path object" ) + @listpath.should_receive( :+ ).with( 'remote' ).twice.and_return( remote_path_obj ) + remote_path_obj.should_receive( :exist? ).twice.and_return( true ) + + # Try to read directory names from both config files + remote_path_obj.should_receive( :read ).with( 1 ).and_return( '/' ) + remote_path_obj.should_receive( :read ).with().and_return( TEST_CUSTOM_MODERATORS_DIR ) + + custom_mod_path = mock( "Mock path object for customized moderator dir" ) + Pathname.should_receive( :new ).with( TEST_CUSTOM_MODERATORS_DIR ).and_return( custom_mod_path ) + + # Read subscribers from the default file + custom_mod_path.should_receive( :+ ).with( '*' ).and_return( :mod_sub_dir ) + expectation = Pathname.should_receive( :glob ).with( :mod_sub_dir ) + + TEST_MODERATORS.each do |email| + mock_subfile = mock( "Mock subscribers file for '#{email}'" ) + mock_subfile.should_receive( :read ).and_return( "T#{email}\0" ) + + expectation.and_yield( mock_subfile ) + end + + mods = @list.subscription_moderators + mods.should have(TEST_MODERATORS.length).members + mods.should include( *TEST_MODERATORS ) + end ### Message moderation