-
Notifications
You must be signed in to change notification settings - Fork 0
/
box_synchronizer_spec.rb
43 lines (36 loc) · 1.33 KB
/
box_synchronizer_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'rails_helper'
describe ::DiscourseBackupToBox::BoxSynchronizer do
let(:backup) { Backup.new('backup') }
describe "#backup" do
it "has a reader method for the backup" do
ds = described_class.new(backup)
expect(ds.backup).to eq(backup)
end
end
describe "#can_sync?" do
it "should return false when disabled via site setting" do
SiteSetting.discourse_sync_to_box_enabled = false
SiteSetting.discourse_sync_to_box_api_key = 'test_key'
ds = described_class.new(backup)
expect(ds.can_sync?).to eq(false)
end
it "should return false when the backup is missing" do
SiteSetting.discourse_sync_to_box_enabled = true
SiteSetting.discourse_sync_to_box_api_key = 'test_key'
ds = described_class.new(nil)
expect(ds.can_sync?).to eq(false)
end
it "should return false when the api key is missing" do
SiteSetting.discourse_sync_to_box_enabled = true
SiteSetting.discourse_sync_to_box_api_key = ''
ds = described_class.new(backup)
expect(ds.can_sync?).to eq(false)
end
it "should return true when everything is correct" do
SiteSetting.discourse_sync_to_box_enabled = true
SiteSetting.discourse_sync_to_box_api_key = 'test_key'
ds = described_class.new(backup)
expect(ds.can_sync?).to eq(true)
end
end
end