Add a test for a customized moderator's directory in the dir/remote file.
authorMichael Granger <mgranger@laika.com>
Thu, 08 May 2008 21:32:18 +0000
changeset 3 9b9e85ccf4f9
parent 2 7b5a0131d5cd
child 4 8c4ae0797d5f
Add a test for a customized moderator's directory in the dir/remote file. (with Michael)
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