imap-backup 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/README.md +6 -2
- data/bin/imap-backup +1 -1
- data/lib/email/mboxrd/message.rb +0 -1
- data/lib/imap/backup/account/connection.rb +28 -21
- data/lib/imap/backup/account/folder.rb +0 -1
- data/lib/imap/backup/serializer/mbox_enumerator.rb +1 -1
- data/lib/imap/backup/uploader.rb +10 -1
- data/lib/imap/backup/version.rb +2 -2
- data/spec/features/restore_spec.rb +75 -27
- data/spec/features/support/email_server.rb +1 -3
- data/spec/features/support/shared/message_fixtures.rb +8 -0
- data/spec/unit/email/mboxrd/message_spec.rb +0 -6
- data/spec/unit/imap/backup/account/connection_spec.rb +58 -43
- data/spec/unit/imap/backup/account/folder_spec.rb +16 -20
- data/spec/unit/imap/backup/configuration/account_spec.rb +31 -25
- data/spec/unit/imap/backup/configuration/asker_spec.rb +20 -17
- data/spec/unit/imap/backup/configuration/connection_tester_spec.rb +6 -10
- data/spec/unit/imap/backup/configuration/folder_chooser_spec.rb +16 -10
- data/spec/unit/imap/backup/configuration/list_spec.rb +6 -3
- data/spec/unit/imap/backup/configuration/setup_spec.rb +40 -25
- data/spec/unit/imap/backup/configuration/store_spec.rb +18 -16
- data/spec/unit/imap/backup/downloader_spec.rb +14 -14
- data/spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb +6 -1
- data/spec/unit/imap/backup/serializer/mbox_spec.rb +54 -40
- data/spec/unit/imap/backup/serializer/mbox_store_spec.rb +49 -31
- data/spec/unit/imap/backup/uploader_spec.rb +20 -7
- data/spec/unit/imap/backup/utils_spec.rb +8 -9
- metadata +2 -2
@@ -2,7 +2,9 @@ describe Imap::Backup::Uploader do
|
|
2
2
|
subject { described_class.new(folder, serializer) }
|
3
3
|
|
4
4
|
let(:folder) do
|
5
|
-
instance_double(
|
5
|
+
instance_double(
|
6
|
+
Imap::Backup::Account::Folder, uids: [2, 3], append: 99, name: "foo"
|
7
|
+
)
|
6
8
|
end
|
7
9
|
let(:serializer) do
|
8
10
|
instance_double(
|
@@ -11,27 +13,38 @@ describe Imap::Backup::Uploader do
|
|
11
13
|
update_uid: nil
|
12
14
|
)
|
13
15
|
end
|
16
|
+
let(:missing_message) do
|
17
|
+
instance_double(Email::Mboxrd::Message, supplied_body: "missing message")
|
18
|
+
end
|
19
|
+
let(:existing_message) do
|
20
|
+
instance_double(Email::Mboxrd::Message, supplied_body: "existing message")
|
21
|
+
end
|
14
22
|
|
15
23
|
describe "#run" do
|
16
24
|
before do
|
17
|
-
allow(serializer).to receive(:load).with(1) {
|
18
|
-
allow(serializer).to receive(:load).with(2) {
|
19
|
-
subject.run
|
25
|
+
allow(serializer).to receive(:load).with(1) { missing_message }
|
26
|
+
allow(serializer).to receive(:load).with(2) { existing_message }
|
20
27
|
end
|
21
28
|
|
22
29
|
context "with messages that are missing" do
|
23
30
|
it "restores them" do
|
24
|
-
expect(folder).to
|
31
|
+
expect(folder).to receive(:append).with(missing_message)
|
32
|
+
|
33
|
+
subject.run
|
25
34
|
end
|
26
35
|
|
27
36
|
it "updates the local message id" do
|
28
|
-
expect(serializer).to
|
37
|
+
expect(serializer).to receive(:update_uid).with(1, 99)
|
38
|
+
|
39
|
+
subject.run
|
29
40
|
end
|
30
41
|
end
|
31
42
|
|
32
43
|
context "with messages that are present on server" do
|
33
44
|
it "does nothing" do
|
34
|
-
expect(folder).to_not
|
45
|
+
expect(folder).to_not receive(:append).with(existing_message)
|
46
|
+
|
47
|
+
subject.run
|
35
48
|
end
|
36
49
|
end
|
37
50
|
end
|
@@ -5,8 +5,8 @@ describe Imap::Backup::Utils do
|
|
5
5
|
let(:exists) { true }
|
6
6
|
|
7
7
|
before do
|
8
|
-
allow(File).to receive(:stat)
|
9
|
-
allow(File).to receive(:exist?).with(filename)
|
8
|
+
allow(File).to receive(:stat) { stat }
|
9
|
+
allow(File).to receive(:exist?).with(filename) { exists }
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".check_permissions" do
|
@@ -72,22 +72,21 @@ describe Imap::Backup::Utils do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "does nothing if an empty path is supplied" do
|
75
|
-
|
75
|
+
expect(FileUtils).to_not receive(:mkdir_p)
|
76
76
|
|
77
|
-
|
77
|
+
described_class.make_folder("aaa", "", 0o222)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "creates the path" do
|
81
|
-
|
81
|
+
expect(FileUtils).to receive(:mkdir_p).with("/base/path/new/folder")
|
82
82
|
|
83
|
-
|
83
|
+
described_class.make_folder("/base/path", "new/folder", 0o222)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "sets permissions on the path" do
|
87
|
-
|
87
|
+
expect(FileUtils).to receive(:chmod).with(0o222, "/base/path/new/folder")
|
88
88
|
|
89
|
-
|
90
|
-
to have_received(:chmod).with(0o222, "/base/path/new/folder")
|
89
|
+
described_class.make_folder("/base/path/new", "folder", 0o222)
|
91
90
|
end
|
92
91
|
end
|
93
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imap-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|