spec/ezmlm/list_spec.rb
author Michael Granger <mgranger@laika.com>
Thu, 08 May 2008 21:32:18 +0000
changeset 3 9b9e85ccf4f9
parent 2 7b5a0131d5cd
child 4 8c4ae0797d5f
permissions -rw-r--r--
Add a test for a customized moderator's directory in the dir/remote file. (with Michael)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     1
#!/usr/bin/env ruby
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     2
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     3
BEGIN {
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     4
	require 'pathname'
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     5
	basedir = Pathname.new( __FILE__ ).dirname.parent.parent
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     6
	
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     7
	libdir = basedir + "lib"
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     8
	
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     9
	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    10
}
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    11
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    12
begin
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    13
	require 'spec/runner'
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    14
	require 'spec/lib/helpers'
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    15
	require 'ezmlm/list'
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    16
rescue LoadError
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    17
	unless Object.const_defined?( :Gem )
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    18
		require 'rubygems'
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    19
		retry
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    20
	end
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    21
	raise
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    22
end
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    23
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    24
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    25
describe Ezmlm::List do
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    26
	include Ezmlm::SpecHelpers
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    27
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    28
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    29
	LISTDIR = Pathname.new( 'list' )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    30
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    31
	TEST_SUBSCRIBERS = %w[
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    32
		pete.chaffee@toadsmackers.com
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    33
		dolphinzombie@alahalohamorra.com
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    34
		piratebanker@yahoo.com
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    35
	  ]
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    36
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    37
	TEST_MODERATORS = %w[
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    38
		dolphinzombie@alahalohamorra.com
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    39
	  ]
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    40
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    41
	TEST_OWNER = 'listowner@rumpus-the-whale.info'
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    42
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    43
	TEST_CUSTOM_MODERATORS_DIR = '/foo/bar/clowns'
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    44
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    45
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    46
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    47
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    48
	it "can create a new list"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    49
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    50
	### 
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    51
	### List manager functions
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    52
	### 
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    53
	describe "list manager functions" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    54
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    55
		before( :each ) do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    56
			@listpath = LISTDIR.dup
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    57
			@list = Ezmlm::List.new( @listpath )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    58
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    59
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    60
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    61
		it "can return a list of subscribers' email addresses" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    62
			subscribers_dir = LISTDIR + 'subscribers'
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    63
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    64
			expectation = Pathname.should_receive( :glob ).with( subscribers_dir + '*' )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    65
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    66
			TEST_SUBSCRIBERS.each do |email|
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    67
				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    68
				mock_subfile.should_receive( :read ).and_return( "T#{email}\0" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    69
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    70
				expectation.and_yield( mock_subfile )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    71
			end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    72
				
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    73
			subscribers = @list.subscribers
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    74
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    75
			subscribers.should have(TEST_SUBSCRIBERS.length).members
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    76
			subscribers.should include( *TEST_SUBSCRIBERS )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    77
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    78
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    79
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    80
		### Subscriber moderation
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    81
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    82
		it "knows that subscription moderation is enabled if the dir/modsub file exists" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    83
			modsub_path_obj = mock( "Mock 'modsub' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    84
			@listpath.should_receive( :+ ).with( 'modsub' ).and_return( modsub_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    85
			modsub_path_obj.should_receive( :exist? ).and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    86
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    87
			@list.should be_closed()
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    88
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    89
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    90
		it "knows that subscription moderation is enabled if the dir/remote file exists" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    91
			modsub_path_obj = mock( "Mock 'modsub' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    92
			@listpath.should_receive( :+ ).with( 'modsub' ).and_return( modsub_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    93
			modsub_path_obj.should_receive( :exist? ).and_return( false )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    94
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    95
			remote_path_obj = mock( "Mock 'remote' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    96
			@listpath.should_receive( :+ ).with( 'remote' ).and_return( remote_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    97
			remote_path_obj.should_receive( :exist? ).and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    98
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    99
			@list.should be_closed()
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   100
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   101
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   102
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   103
		it "knows that subscription moderation is disabled if neither the dir/modsub nor " +
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   104
		   "dir/remote files exist" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   105
			modsub_path_obj = mock( "Mock 'modsub' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   106
			@listpath.should_receive( :+ ).with( 'modsub' ).and_return( modsub_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   107
			modsub_path_obj.should_receive( :exist? ).and_return( false )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   108
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   109
			remote_path_obj = mock( "Mock 'remote' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   110
			@listpath.should_receive( :+ ).with( 'remote' ).and_return( remote_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   111
			remote_path_obj.should_receive( :exist? ).and_return( false )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   112
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   113
			@list.should_not be_closed()
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   114
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   115
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   116
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   117
		it "returns an empty array of subscription moderators for an open list" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   118
			modsub_path_obj = mock( "Mock 'modsub' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   119
			@listpath.should_receive( :+ ).with( 'modsub' ).and_return( modsub_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   120
			modsub_path_obj.should_receive( :exist? ).and_return( false )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   121
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   122
			remote_path_obj = mock( "Mock 'remote' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   123
			@listpath.should_receive( :+ ).with( 'remote' ).and_return( remote_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   124
			remote_path_obj.should_receive( :exist? ).and_return( false )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   125
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   126
			@list.subscription_moderators.should be_empty()
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   127
		end
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
   128
	
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   129
		it "can return a list of subscription moderators' email addresses" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   130
			# Test the moderation config files for existence
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   131
			modsub_path_obj = mock( "Mock 'modsub' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   132
			@listpath.should_receive( :+ ).with( 'modsub' ).twice.and_return( modsub_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   133
			modsub_path_obj.should_receive( :exist? ).twice.and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   134
			remote_path_obj = mock( "Mock 'remote' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   135
			@listpath.should_receive( :+ ).with( 'remote' ).and_return( remote_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   136
			remote_path_obj.should_receive( :exist? ).once.and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   137
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   138
			# Try to read directory names from both config files
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   139
			modsub_path_obj.should_receive( :read ).with( 1 ).and_return( nil )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   140
			remote_path_obj.should_receive( :read ).with( 1 ).and_return( nil )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   141
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   142
			# Read subscribers from the default directory
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   143
			subscribers_dir = mock( "Mock moderator subscribers directory" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   144
			@listpath.should_receive( :+ ).with( 'mod/subscribers' ).and_return( subscribers_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   145
			subscribers_dir.should_receive( :+ ).with( '*' ).and_return( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   146
			expectation = Pathname.should_receive( :glob ).with( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   147
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   148
			TEST_MODERATORS.each do |email|
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   149
				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   150
				mock_subfile.should_receive( :read ).and_return( "T#{email}\0" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   151
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   152
				expectation.and_yield( mock_subfile )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   153
			end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   154
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   155
			mods = @list.subscription_moderators
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   156
			mods.should have(TEST_MODERATORS.length).members
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   157
			mods.should include( *TEST_MODERATORS )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   158
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   159
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   160
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   161
		it "can return a list of subscription moderators' email addresses when the moderators " +
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   162
		   "directory has been customized" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   163
			# Test the moderation config files for existence
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   164
			modsub_path_obj = mock( "Mock 'modsub' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   165
			@listpath.should_receive( :+ ).with( 'modsub' ).twice.and_return( modsub_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   166
			modsub_path_obj.should_receive( :exist? ).twice.and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   167
			@listpath.should_receive( :+ ).with( 'remote' )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   168
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   169
			# Try to read directory names from both config files
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   170
			modsub_path_obj.should_receive( :read ).with( 1 ).and_return( '/' )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   171
			modsub_path_obj.should_receive( :read ).with().and_return( TEST_CUSTOM_MODERATORS_DIR )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   172
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   173
			custom_mod_path = mock( "Mock path object for customized moderator dir" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   174
			Pathname.should_receive( :new ).with( TEST_CUSTOM_MODERATORS_DIR ).and_return( custom_mod_path )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   175
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   176
			# Read subscribers from the default file
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   177
			custom_mod_path.should_receive( :+ ).with( '*' ).and_return( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   178
			expectation = Pathname.should_receive( :glob ).with( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   179
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   180
			TEST_MODERATORS.each do |email|
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   181
				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   182
				mock_subfile.should_receive( :read ).and_return( "T#{email}\0" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   183
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   184
				expectation.and_yield( mock_subfile )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   185
			end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   186
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   187
			mods = @list.subscription_moderators
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   188
			mods.should have(TEST_MODERATORS.length).members
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   189
			mods.should include( *TEST_MODERATORS )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   190
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   191
		
3
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   192
		it "can get a list of modererators when remote subscription moderation is enabled" +
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   193
           " and the modsub configuration is empty" do
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   194
			# Test the moderation config files for existence
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   195
			modsub_path_obj = mock( "Mock 'modsub' path object" )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   196
			@listpath.should_receive( :+ ).with( 'modsub' ).twice.and_return( modsub_path_obj )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   197
			modsub_path_obj.should_receive( :exist? ).twice.and_return( false )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   198
            remote_path_obj = mock( "Mock 'remote' path object" )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   199
			@listpath.should_receive( :+ ).with( 'remote' ).twice.and_return( remote_path_obj )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   200
            remote_path_obj.should_receive( :exist? ).twice.and_return( true )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   201
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   202
			# Try to read directory names from both config files
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   203
			remote_path_obj.should_receive( :read ).with( 1 ).and_return( '/' )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   204
			remote_path_obj.should_receive( :read ).with().and_return( TEST_CUSTOM_MODERATORS_DIR )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   205
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   206
			custom_mod_path = mock( "Mock path object for customized moderator dir" )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   207
			Pathname.should_receive( :new ).with( TEST_CUSTOM_MODERATORS_DIR ).and_return( custom_mod_path )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   208
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   209
			# Read subscribers from the default file
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   210
			custom_mod_path.should_receive( :+ ).with( '*' ).and_return( :mod_sub_dir )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   211
			expectation = Pathname.should_receive( :glob ).with( :mod_sub_dir )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   212
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   213
			TEST_MODERATORS.each do |email|
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   214
				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   215
				mock_subfile.should_receive( :read ).and_return( "T#{email}\0" )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   216
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   217
				expectation.and_yield( mock_subfile )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   218
			end
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   219
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   220
			mods = @list.subscription_moderators
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   221
			mods.should have(TEST_MODERATORS.length).members
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   222
			mods.should include( *TEST_MODERATORS )
9b9e85ccf4f9 Add a test for a customized moderator's directory in the dir/remote file.
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   223
		end
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   224
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   225
		### Message moderation
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   226
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   227
		it "knows that subscription moderation is enabled if the dir/modpost file exists" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   228
			modpost_path_obj = mock( "Mock 'modpost' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   229
			@listpath.should_receive( :+ ).with( 'modpost' ).and_return( modpost_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   230
			modpost_path_obj.should_receive( :exist? ).and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   231
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   232
			@list.should be_moderated()
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   233
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   234
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   235
		it "knows that subscription moderation is disabled if the dir/modpost file doesn't exist" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   236
			modpost_path_obj = mock( "Mock 'modpost' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   237
			@listpath.should_receive( :+ ).with( 'modpost' ).and_return( modpost_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   238
			modpost_path_obj.should_receive( :exist? ).and_return( false )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   239
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   240
			@list.should_not be_moderated()
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   241
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   242
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   243
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   244
		it "returns an empty array of message moderators for an open list" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   245
			modpost_path_obj = mock( "Mock 'modpost' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   246
			@listpath.should_receive( :+ ).with( 'modpost' ).and_return( modpost_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   247
			modpost_path_obj.should_receive( :exist? ).and_return( false )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   248
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   249
			@list.message_moderators.should be_empty()
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   250
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   251
	
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   252
	
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   253
		it "can return a list of message moderators' email addresses" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   254
			# Test the moderation config file for existence
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   255
			modpost_path_obj = mock( "Mock 'modpost' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   256
			@listpath.should_receive( :+ ).with( 'modpost' ).twice.and_return( modpost_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   257
			modpost_path_obj.should_receive( :exist? ).twice.and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   258
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   259
			# Try to read directory names from the config file
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   260
			modpost_path_obj.should_receive( :read ).with( 1 ).and_return( nil )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   261
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   262
			# Read subscribers from the default directory
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   263
			subscribers_dir = mock( "Mock moderator subscribers directory" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   264
			@listpath.should_receive( :+ ).with( 'mod/subscribers' ).and_return( subscribers_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   265
			subscribers_dir.should_receive( :+ ).with( '*' ).and_return( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   266
			expectation = Pathname.should_receive( :glob ).with( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   267
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   268
			TEST_MODERATORS.each do |email|
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   269
				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   270
				mock_subfile.should_receive( :read ).and_return( "T#{email}\0" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   271
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   272
				expectation.and_yield( mock_subfile )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   273
			end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   274
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   275
			mods = @list.message_moderators
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   276
			mods.should have(TEST_MODERATORS.length).members
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   277
			mods.should include( *TEST_MODERATORS )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   278
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   279
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   280
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   281
		it "can return a list of message moderators' email addresses when the moderators " +
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   282
		   "directory has been customized" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   283
			# Test the moderation config files for existence
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   284
			modpost_path_obj = mock( "Mock 'modpost' path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   285
			@listpath.should_receive( :+ ).with( 'modpost' ).twice.and_return( modpost_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   286
			modpost_path_obj.should_receive( :exist? ).twice.and_return( true )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   287
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   288
			# Try to read directory names from both config files
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   289
			modpost_path_obj.should_receive( :read ).with( 1 ).and_return( '/' )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   290
			modpost_path_obj.should_receive( :read ).with().and_return( TEST_CUSTOM_MODERATORS_DIR )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   291
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   292
			custom_mod_path = mock( "Mock path object for customized moderator dir" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   293
			Pathname.should_receive( :new ).with( TEST_CUSTOM_MODERATORS_DIR ).and_return( custom_mod_path )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   294
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   295
			# Read subscribers from the default file
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   296
			custom_mod_path.should_receive( :+ ).with( '*' ).and_return( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   297
			expectation = Pathname.should_receive( :glob ).with( :mod_sub_dir )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   298
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   299
			TEST_MODERATORS.each do |email|
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   300
				mock_subfile = mock( "Mock subscribers file for '#{email}'" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   301
				mock_subfile.should_receive( :read ).and_return( "T#{email}\0" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   302
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   303
				expectation.and_yield( mock_subfile )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   304
			end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   305
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   306
			mods = @list.message_moderators
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   307
			mods.should have(TEST_MODERATORS.length).members
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   308
			mods.should include( *TEST_MODERATORS )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   309
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   310
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   311
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   312
		### List owner
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   313
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   314
		TEST_CONFIG_WITHOUT_OWNER = <<-"EOF".gsub( /^\t+/, '' )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   315
		F:-aBCDeFGHijKlMnOpQrStUVWXYZ
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   316
		X:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   317
		D:/var/qmail/alias/lists/waffle-lovers/
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   318
		T:/var/qmail/alias/.qmail-waffle-lovers
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   319
		L:waffle-lovers
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   320
		H:lists.syrup.info
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   321
		C:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   322
		0:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   323
		3:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   324
		4:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   325
		5:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   326
		6:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   327
		7:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   328
		8:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   329
		9:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   330
		EOF
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   331
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   332
		it "returns nil when the list doesn't have an owner in its config" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   333
			config_path_obj = mock( "Config path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   334
			@listpath.should_receive( :+ ).with( 'config' ).and_return( config_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   335
			config_path_obj.should_receive( :read ).and_return( TEST_CONFIG_WITHOUT_OWNER )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   336
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   337
			@list.owner.should == nil
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   338
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   339
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   340
			
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   341
		TEST_CONFIG_WITH_OWNER = <<-"EOF".gsub( /^\t+/, '' )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   342
		F:-aBCDeFGHijKlMnOpQrStUVWXYZ
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   343
		X:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   344
		D:/var/qmail/alias/lists/waffle-lovers/
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   345
		T:/var/qmail/alias/.qmail-waffle-lovers
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   346
		L:waffle-lovers
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   347
		H:lists.syrup.info
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   348
		C:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   349
		0:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   350
		3:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   351
		4:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   352
		5:#{TEST_OWNER}
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   353
		6:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   354
		7:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   355
		8:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   356
		9:
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   357
		EOF
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   358
		
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   359
		it "can return the email address of the list owner" do
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   360
			config_path_obj = mock( "Config path object" )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   361
			@listpath.should_receive( :+ ).with( 'config' ).and_return( config_path_obj )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   362
			config_path_obj.should_receive( :read ).and_return( TEST_CONFIG_WITH_OWNER )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   363
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   364
			@list.owner.should == TEST_OWNER
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   365
		end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   366
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   367
	end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   368
	
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   369
	### 
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   370
	### Archive functions
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   371
	### 
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   372
	it "can return the count of archived posts"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   373
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   374
	it "can return a hash of the subjects of all archived posts to message ids"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   375
	it "can return an Array of the subjects of all archived posts"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   376
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   377
	it "can return a hash of the threads of all archived posts to message ids"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   378
	it "can return an Array of the threads of all archived posts"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   379
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   380
	it "can return a hash of the authors of all archived posts to message ids"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   381
	it "can return an Array of the authors of all archived posts"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   382
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   383
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   384
	it "can fetch the body of an archived post by message id"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   385
	it "can fetch the header of an archived post by message id"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   386
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   387
	it "can fetch the date of the last archived post"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   388
	it "can fetch the author of the last archived post"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   389
	it "can fetch the subject of the last archived post"
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   390
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
   391
end
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
   392
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
   393