imap-backup 4.0.4 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/imap-backup +5 -2
- data/lib/email/provider/apple_mail.rb +2 -2
- data/lib/email/provider/base.rb +8 -0
- data/lib/email/provider/fastmail.rb +2 -2
- data/lib/email/provider/gmail.rb +2 -2
- data/lib/email/provider/{default.rb → unknown.rb} +2 -3
- data/lib/email/provider.rb +2 -2
- data/lib/imap/backup/account/connection.rb +70 -58
- data/lib/imap/backup/account/folder.rb +23 -3
- data/lib/imap/backup/account.rb +102 -0
- data/lib/imap/backup/cli/accounts.rb +43 -0
- data/lib/imap/backup/cli/folders.rb +3 -1
- data/lib/imap/backup/cli/helpers.rb +8 -9
- data/lib/imap/backup/cli/local.rb +4 -2
- data/lib/imap/backup/cli/setup.rb +1 -1
- data/lib/imap/backup/cli/utils.rb +3 -2
- data/lib/imap/backup/{configuration/store.rb → configuration.rb} +49 -14
- data/lib/imap/backup/downloader.rb +26 -12
- data/lib/imap/backup/logger.rb +42 -0
- data/lib/imap/backup/sanitizer.rb +42 -0
- data/lib/imap/backup/serializer/mbox_store.rb +2 -2
- data/lib/imap/backup/setup/account.rb +177 -0
- data/lib/imap/backup/{configuration → setup}/asker.rb +5 -5
- data/lib/imap/backup/setup/connection_tester.rb +26 -0
- data/lib/imap/backup/{configuration → setup}/folder_chooser.rb +25 -17
- data/lib/imap/backup/setup/helpers.rb +15 -0
- data/lib/imap/backup/{configuration/setup.rb → setup.rb} +33 -25
- data/lib/imap/backup/uploader.rb +2 -2
- data/lib/imap/backup/version.rb +2 -2
- data/lib/imap/backup.rb +7 -33
- data/lib/retry_on_error.rb +1 -1
- data/spec/features/backup_spec.rb +1 -0
- data/spec/features/support/email_server.rb +5 -2
- data/spec/features/support/shared/connection_context.rb +7 -5
- data/spec/support/higline_test_helpers.rb +1 -1
- data/spec/support/silence_logging.rb +1 -1
- data/spec/unit/email/provider/{default_spec.rb → base_spec.rb} +1 -7
- data/spec/unit/email/provider_spec.rb +2 -2
- data/spec/unit/imap/backup/account/connection_spec.rb +22 -26
- data/spec/unit/imap/backup/cli/accounts_spec.rb +47 -0
- data/spec/unit/imap/backup/cli/local_spec.rb +15 -4
- data/spec/unit/imap/backup/cli/utils_spec.rb +54 -42
- data/spec/unit/imap/backup/{configuration/store_spec.rb → configuration_spec.rb} +23 -24
- data/spec/unit/imap/backup/downloader_spec.rb +1 -1
- data/spec/unit/imap/backup/logger_spec.rb +48 -0
- data/spec/unit/imap/backup/{configuration → setup}/account_spec.rb +78 -70
- data/spec/unit/imap/backup/{configuration → setup}/asker_spec.rb +2 -2
- data/spec/unit/imap/backup/{configuration → setup}/connection_tester_spec.rb +10 -10
- data/spec/unit/imap/backup/{configuration → setup}/folder_chooser_spec.rb +25 -26
- data/spec/unit/imap/backup/{configuration/setup_spec.rb → setup_spec.rb} +81 -52
- metadata +54 -51
- data/lib/imap/backup/configuration/account.rb +0 -159
- data/lib/imap/backup/configuration/connection_tester.rb +0 -14
- data/lib/imap/backup/configuration/list.rb +0 -53
- data/spec/support/shared_examples/account_flagging.rb +0 -23
- data/spec/unit/imap/backup/configuration/list_spec.rb +0 -89
- data/spec/unit/imap/backup_spec.rb +0 -28
@@ -1,23 +0,0 @@
|
|
1
|
-
shared_examples "it flags the account as modified" do
|
2
|
-
it "flags that the account has changed" do
|
3
|
-
expect(account[:modified]).to be_truthy
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
shared_examples "it doesn't flag the account as modified" do
|
8
|
-
it "does not flag that the account has changed" do
|
9
|
-
expect(account[:modified]).to be_falsey
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
shared_examples "it flags the account to be deleted" do
|
14
|
-
it "flags that the account is to be deleted" do
|
15
|
-
expect(account[:delete]).to be_truthy
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
shared_examples "it doesn't flag the account to be deleted" do
|
20
|
-
it "does not flags that the account is to be deleted" do
|
21
|
-
expect(account[:delete]).to be_falsey
|
22
|
-
end
|
23
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
describe Imap::Backup::Configuration::List do
|
2
|
-
subject { described_class.new }
|
3
|
-
|
4
|
-
let(:accounts) do
|
5
|
-
[
|
6
|
-
{username: "a1@example.com"},
|
7
|
-
{username: "a2@example.com"}
|
8
|
-
]
|
9
|
-
end
|
10
|
-
let(:store) do
|
11
|
-
instance_double(Imap::Backup::Configuration::Store, accounts: accounts)
|
12
|
-
end
|
13
|
-
let(:exists) { true }
|
14
|
-
let(:connection1) do
|
15
|
-
instance_double(Imap::Backup::Account::Connection, disconnect: nil)
|
16
|
-
end
|
17
|
-
let(:connection2) do
|
18
|
-
instance_double(Imap::Backup::Account::Connection, disconnect: nil)
|
19
|
-
end
|
20
|
-
|
21
|
-
before do
|
22
|
-
allow(Imap::Backup::Configuration::Store).to receive(:new) { store }
|
23
|
-
allow(Imap::Backup::Configuration::Store).
|
24
|
-
to receive(:exist?) { exists }
|
25
|
-
allow(Imap::Backup::Account::Connection).
|
26
|
-
to receive(:new).with(accounts[0]) { connection1 }
|
27
|
-
allow(Imap::Backup::Account::Connection).
|
28
|
-
to receive(:new).with(accounts[1]) { connection2 }
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#setup_logging" do
|
32
|
-
let(:config_exists) { true }
|
33
|
-
|
34
|
-
before do
|
35
|
-
allow(Imap::Backup::Configuration::Store).
|
36
|
-
to receive(:exist?) { config_exists }
|
37
|
-
allow(Imap::Backup).to receive(:setup_logging)
|
38
|
-
allow(store).to receive(:debug?)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets global logging level" do
|
42
|
-
expect(Imap::Backup).to receive(:setup_logging).with(store)
|
43
|
-
|
44
|
-
subject.setup_logging
|
45
|
-
end
|
46
|
-
|
47
|
-
context "without a config" do
|
48
|
-
let(:config_exists) { false }
|
49
|
-
|
50
|
-
it "does nothing" do
|
51
|
-
expect(Imap::Backup).to_not receive(:setup_logging).with(store)
|
52
|
-
|
53
|
-
subject.setup_logging
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "#each_connection" do
|
59
|
-
specify "calls the block with each account's connection" do
|
60
|
-
connections = []
|
61
|
-
|
62
|
-
subject.each_connection { |a| connections << a }
|
63
|
-
|
64
|
-
expect(connections).to eq([connection1, connection2])
|
65
|
-
end
|
66
|
-
|
67
|
-
context "with account parameter" do
|
68
|
-
subject { described_class.new(["a2@example.com"]) }
|
69
|
-
|
70
|
-
it "only creates requested accounts" do
|
71
|
-
connections = []
|
72
|
-
|
73
|
-
subject.each_connection { |a| connections << a }
|
74
|
-
|
75
|
-
expect(connections).to eq([connection2])
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "when the configuration file is missing" do
|
80
|
-
let(:exists) { false }
|
81
|
-
|
82
|
-
it "fails" do
|
83
|
-
expect do
|
84
|
-
subject.each_connection {}
|
85
|
-
end.to raise_error(Imap::Backup::ConfigurationNotFound, /not found/)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require "ostruct"
|
2
|
-
require "imap/backup"
|
3
|
-
|
4
|
-
describe Imap::Backup do
|
5
|
-
describe ".setup_logging" do
|
6
|
-
let!(:previous) { described_class.logger.level }
|
7
|
-
|
8
|
-
before { described_class.setup_logging(config) }
|
9
|
-
|
10
|
-
after { described_class.logger.level = previous }
|
11
|
-
|
12
|
-
context "when config.debug?" do
|
13
|
-
let(:config) { OpenStruct.new(debug?: true) }
|
14
|
-
|
15
|
-
it "sets logger level to debug" do
|
16
|
-
expect(described_class.logger.level).to eq(::Logger::Severity::DEBUG)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when not config.debug?" do
|
21
|
-
let(:config) { OpenStruct.new(debug?: false) }
|
22
|
-
|
23
|
-
it "sets logger level to debug" do
|
24
|
-
expect(described_class.logger.level).to eq(::Logger::Severity::ERROR)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|