offroad 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +674 -674
- data/README.rdoc +29 -29
- data/Rakefile +75 -75
- data/TODO +42 -42
- data/lib/app/models/offroad/group_state.rb +85 -85
- data/lib/app/models/offroad/mirror_info.rb +53 -53
- data/lib/app/models/offroad/model_state.rb +36 -36
- data/lib/app/models/offroad/received_record_state.rb +115 -115
- data/lib/app/models/offroad/sendable_record_state.rb +91 -91
- data/lib/app/models/offroad/system_state.rb +33 -33
- data/lib/cargo_streamer.rb +222 -222
- data/lib/controller_extensions.rb +74 -74
- data/lib/exceptions.rb +16 -16
- data/lib/migrate/20100512164608_create_offroad_tables.rb +72 -72
- data/lib/mirror_data.rb +376 -376
- data/lib/model_extensions.rb +378 -377
- data/lib/module_funcs.rb +94 -94
- data/lib/offroad.rb +41 -41
- data/lib/version.rb +3 -3
- data/lib/view_helper.rb +7 -7
- data/templates/offline.rb +36 -36
- data/templates/offline_database.yml +7 -7
- data/templates/offroad.yml +6 -6
- data/test/app_root/app/controllers/application_controller.rb +2 -2
- data/test/app_root/app/controllers/group_controller.rb +28 -28
- data/test/app_root/app/models/global_record.rb +10 -10
- data/test/app_root/app/models/group.rb +12 -12
- data/test/app_root/app/models/group_owned_record.rb +68 -68
- data/test/app_root/app/models/guest.rb +7 -7
- data/test/app_root/app/models/subrecord.rb +12 -12
- data/test/app_root/app/models/unmirrored_record.rb +4 -4
- data/test/app_root/app/views/group/download_down_mirror.html.erb +3 -3
- data/test/app_root/app/views/group/download_initial_down_mirror.html.erb +3 -3
- data/test/app_root/app/views/group/download_up_mirror.html.erb +5 -5
- data/test/app_root/app/views/layouts/mirror.html.erb +8 -8
- data/test/app_root/config/boot.rb +115 -115
- data/test/app_root/config/database-pg.yml +8 -8
- data/test/app_root/config/database.yml +5 -5
- data/test/app_root/config/environment.rb +24 -24
- data/test/app_root/config/environments/test.rb +17 -17
- data/test/app_root/config/offroad.yml +6 -6
- data/test/app_root/config/routes.rb +4 -4
- data/test/app_root/db/migrate/20100529235049_create_tables.rb +64 -64
- data/test/app_root/lib/common_hobo.rb +15 -15
- data/test/app_root/vendor/plugins/offroad/init.rb +2 -2
- data/test/functional/mirror_operations_test.rb +148 -148
- data/test/test_helper.rb +453 -453
- data/test/unit/app_state_tracking_test.rb +275 -275
- data/test/unit/cargo_streamer_test.rb +332 -332
- data/test/unit/global_data_test.rb +102 -102
- data/test/unit/group_controller_test.rb +152 -152
- data/test/unit/group_data_test.rb +442 -435
- data/test/unit/group_single_test.rb +136 -136
- data/test/unit/hobo_permissions_test.rb +57 -57
- data/test/unit/mirror_data_test.rb +1283 -1283
- data/test/unit/mirror_info_test.rb +31 -31
- data/test/unit/module_funcs_test.rb +37 -37
- data/test/unit/pathological_model_test.rb +62 -62
- data/test/unit/test_framework_test.rb +86 -86
- data/test/unit/unmirrored_data_test.rb +14 -14
- metadata +6 -8
@@ -1,102 +1,102 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
-
|
3
|
-
# This is a unit test on the ability of model_extensions to handle global models
|
4
|
-
|
5
|
-
class GlobalDataTest < Test::Unit::TestCase
|
6
|
-
online_test "can create new global records" do
|
7
|
-
assert_nothing_raised do
|
8
|
-
GlobalRecord.create(:title => "Something or other")
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
offline_test "cannot create new global records" do
|
13
|
-
assert_raise ActiveRecord::ReadOnlyRecord do
|
14
|
-
GlobalRecord.create(:title => "Foo bar baz bork")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
double_test "global data models report being global data" do
|
19
|
-
assert GlobalRecord.offroad_global_data?, "Global model should return true to offroad_global_data?"
|
20
|
-
assert_equal false, GlobalRecord.offroad_group_data?, "Global model should return false to offroad_group_data?"
|
21
|
-
end
|
22
|
-
|
23
|
-
online_test "global data is writable and destroyable" do
|
24
|
-
global_record = GlobalRecord.create(:title => "Something or other")
|
25
|
-
assert !global_record.locked_by_offroad?
|
26
|
-
assert_nothing_raised do
|
27
|
-
global_record.title = "Something else"
|
28
|
-
global_record.save!
|
29
|
-
global_record.destroy
|
30
|
-
end
|
31
|
-
|
32
|
-
if HOBO_TEST_MODE
|
33
|
-
guest = Guest.new
|
34
|
-
global_record.permissive = true
|
35
|
-
assert global_record.creatable_by?(guest)
|
36
|
-
assert global_record.updatable_by?(guest)
|
37
|
-
assert global_record.destroyable_by?(guest)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
offline_test "global data is not writable or destroyable" do
|
42
|
-
global_record = GlobalRecord.new(:title => "Something or other")
|
43
|
-
force_save_and_reload(global_record)
|
44
|
-
assert global_record.locked_by_offroad?
|
45
|
-
|
46
|
-
assert_raise ActiveRecord::ReadOnlyRecord, "expect exception on title change" do
|
47
|
-
global_record.title = "Something else"
|
48
|
-
global_record.save!
|
49
|
-
end
|
50
|
-
|
51
|
-
assert_raise ActiveRecord::ReadOnlyRecord, "expect exception on destroy" do
|
52
|
-
global_record.destroy
|
53
|
-
end
|
54
|
-
|
55
|
-
if HOBO_TEST_MODE
|
56
|
-
guest = Guest.new
|
57
|
-
global_record.permissive = true
|
58
|
-
assert !global_record.creatable_by?(guest)
|
59
|
-
assert !global_record.updatable_by?(guest)
|
60
|
-
assert !global_record.destroyable_by?(guest)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
online_test "cannot change id of global data" do
|
65
|
-
global_record = GlobalRecord.create(:title => "Something or other")
|
66
|
-
assert_raise Offroad::DataError do
|
67
|
-
global_record.id += 1
|
68
|
-
global_record.save!
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
online_test "global data can hold a foreign key to other global data" do
|
73
|
-
global_record = GlobalRecord.create(:title => "Something or other")
|
74
|
-
another_global_record = GlobalRecord.create(:title => "Yet Another")
|
75
|
-
|
76
|
-
assert_nothing_raised do
|
77
|
-
global_record.friend = another_global_record
|
78
|
-
global_record.save!
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
online_test "global data cannot hold a foreign key to group data" do
|
83
|
-
global_record = GlobalRecord.create(:title => "Something or other")
|
84
|
-
assert_raise Offroad::DataError do
|
85
|
-
global_record.some_group = @offline_group
|
86
|
-
global_record.save!
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
online_test "global data cannot hold a foreign key to unmirrored data" do
|
91
|
-
global_record = GlobalRecord.create(:title => "Something or other")
|
92
|
-
unmirrored_data = UnmirroredRecord.create(:content => "Some Unmirrored Data")
|
93
|
-
assert_raise Offroad::DataError do
|
94
|
-
global_record.unmirrored_record = unmirrored_data
|
95
|
-
global_record.save!
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
double_test "global data models return true to acts_as_offroadable?" do
|
100
|
-
assert GlobalRecord.acts_as_offroadable?
|
101
|
-
end
|
102
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
# This is a unit test on the ability of model_extensions to handle global models
|
4
|
+
|
5
|
+
class GlobalDataTest < Test::Unit::TestCase
|
6
|
+
online_test "can create new global records" do
|
7
|
+
assert_nothing_raised do
|
8
|
+
GlobalRecord.create(:title => "Something or other")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
offline_test "cannot create new global records" do
|
13
|
+
assert_raise ActiveRecord::ReadOnlyRecord do
|
14
|
+
GlobalRecord.create(:title => "Foo bar baz bork")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
double_test "global data models report being global data" do
|
19
|
+
assert GlobalRecord.offroad_global_data?, "Global model should return true to offroad_global_data?"
|
20
|
+
assert_equal false, GlobalRecord.offroad_group_data?, "Global model should return false to offroad_group_data?"
|
21
|
+
end
|
22
|
+
|
23
|
+
online_test "global data is writable and destroyable" do
|
24
|
+
global_record = GlobalRecord.create(:title => "Something or other")
|
25
|
+
assert !global_record.locked_by_offroad?
|
26
|
+
assert_nothing_raised do
|
27
|
+
global_record.title = "Something else"
|
28
|
+
global_record.save!
|
29
|
+
global_record.destroy
|
30
|
+
end
|
31
|
+
|
32
|
+
if HOBO_TEST_MODE
|
33
|
+
guest = Guest.new
|
34
|
+
global_record.permissive = true
|
35
|
+
assert global_record.creatable_by?(guest)
|
36
|
+
assert global_record.updatable_by?(guest)
|
37
|
+
assert global_record.destroyable_by?(guest)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
offline_test "global data is not writable or destroyable" do
|
42
|
+
global_record = GlobalRecord.new(:title => "Something or other")
|
43
|
+
force_save_and_reload(global_record)
|
44
|
+
assert global_record.locked_by_offroad?
|
45
|
+
|
46
|
+
assert_raise ActiveRecord::ReadOnlyRecord, "expect exception on title change" do
|
47
|
+
global_record.title = "Something else"
|
48
|
+
global_record.save!
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_raise ActiveRecord::ReadOnlyRecord, "expect exception on destroy" do
|
52
|
+
global_record.destroy
|
53
|
+
end
|
54
|
+
|
55
|
+
if HOBO_TEST_MODE
|
56
|
+
guest = Guest.new
|
57
|
+
global_record.permissive = true
|
58
|
+
assert !global_record.creatable_by?(guest)
|
59
|
+
assert !global_record.updatable_by?(guest)
|
60
|
+
assert !global_record.destroyable_by?(guest)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
online_test "cannot change id of global data" do
|
65
|
+
global_record = GlobalRecord.create(:title => "Something or other")
|
66
|
+
assert_raise Offroad::DataError do
|
67
|
+
global_record.id += 1
|
68
|
+
global_record.save!
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
online_test "global data can hold a foreign key to other global data" do
|
73
|
+
global_record = GlobalRecord.create(:title => "Something or other")
|
74
|
+
another_global_record = GlobalRecord.create(:title => "Yet Another")
|
75
|
+
|
76
|
+
assert_nothing_raised do
|
77
|
+
global_record.friend = another_global_record
|
78
|
+
global_record.save!
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
online_test "global data cannot hold a foreign key to group data" do
|
83
|
+
global_record = GlobalRecord.create(:title => "Something or other")
|
84
|
+
assert_raise Offroad::DataError do
|
85
|
+
global_record.some_group = @offline_group
|
86
|
+
global_record.save!
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
online_test "global data cannot hold a foreign key to unmirrored data" do
|
91
|
+
global_record = GlobalRecord.create(:title => "Something or other")
|
92
|
+
unmirrored_data = UnmirroredRecord.create(:content => "Some Unmirrored Data")
|
93
|
+
assert_raise Offroad::DataError do
|
94
|
+
global_record.unmirrored_record = unmirrored_data
|
95
|
+
global_record.save!
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
double_test "global data models return true to acts_as_offroadable?" do
|
100
|
+
assert GlobalRecord.acts_as_offroadable?
|
101
|
+
end
|
102
|
+
end
|
@@ -1,152 +1,152 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
-
|
3
|
-
# This just tests the controller's ability to properly access the functionality of the MirrorData class
|
4
|
-
# Tests for the actual generation and processing of mirror files are in mirror_data_test.rb
|
5
|
-
|
6
|
-
class GroupControllerTest < ActionController::TestCase
|
7
|
-
online_test "can retrieve a down mirror file for the offline group" do
|
8
|
-
get :download_down_mirror, "id" => @offline_group.id
|
9
|
-
assert_response :success
|
10
|
-
assert @response.headers["Content-Disposition"].include?("attachment")
|
11
|
-
content = @response.binary_content
|
12
|
-
assert content.include?("downloaded from the Test App online system"), "testapp's down mirror view file used"
|
13
|
-
|
14
|
-
StringIO.open(content) do |sio|
|
15
|
-
cs = Offroad::CargoStreamer.new(sio, "r")
|
16
|
-
mirror_info = cs.first_cargo_element("mirror_info")
|
17
|
-
assert mirror_info.app_mode.downcase.include?("online")
|
18
|
-
assert_equal false, mirror_info.initial_file
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
online_test "can retrieve an initial down mirror file for the offline group" do
|
23
|
-
get :download_initial_down_mirror, "id" => @offline_group.id
|
24
|
-
assert_response :success
|
25
|
-
assert @response.headers["Content-Disposition"].include?("attachment")
|
26
|
-
content = @response.binary_content
|
27
|
-
assert content.include?("downloaded from the Test App online system"), "testapp's down mirror view file used"
|
28
|
-
|
29
|
-
StringIO.open(content) do |sio|
|
30
|
-
cs = Offroad::CargoStreamer.new(sio, "r")
|
31
|
-
mirror_info = cs.first_cargo_element("mirror_info")
|
32
|
-
assert mirror_info.app_mode.downcase.include?("online")
|
33
|
-
assert mirror_info.initial_file
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
offline_test "can retrieve an up mirror file for the offline group" do
|
38
|
-
get :download_up_mirror, "id" => @offline_group.id
|
39
|
-
assert_response :success
|
40
|
-
assert @response.headers["Content-Disposition"].include?("attachment")
|
41
|
-
content = @response.binary_content
|
42
|
-
assert content.include?("to the Test App online system"), "testapp's up mirror view file was used"
|
43
|
-
|
44
|
-
# This tests ViewHelper::link_to_online_app, used from the testapp's up mirror view
|
45
|
-
assert content.include?(">" + Offroad::online_url + "</a>")
|
46
|
-
assert content.include?("href=\"" + Offroad::online_url + "\"")
|
47
|
-
|
48
|
-
StringIO.open(content) do |sio|
|
49
|
-
cs = Offroad::CargoStreamer.new(sio, "r")
|
50
|
-
assert cs.first_cargo_element("mirror_info").app_mode.downcase.include?("offline")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
online_test "cannot retrieve up mirror files" do
|
55
|
-
assert_raise Offroad::PluginError do
|
56
|
-
get :download_up_mirror, "id" => @offline_group.id
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
online_test "cannot retrieve down mirror files for online groups" do
|
61
|
-
assert_raise Offroad::PluginError do
|
62
|
-
get :download_down_mirror, "id" => @online_group.id
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
cross_test "can upload up mirror files" do
|
67
|
-
mirror_data = ""
|
68
|
-
in_offline_app do
|
69
|
-
@offline_group.name = "ABC"
|
70
|
-
@offline_group.save!
|
71
|
-
get :download_up_mirror, "id" => @offline_group.id
|
72
|
-
mirror_data = @response.binary_content
|
73
|
-
end
|
74
|
-
|
75
|
-
in_online_app do
|
76
|
-
post :upload_up_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
77
|
-
assert_response :success
|
78
|
-
@offline_group.reload
|
79
|
-
assert_equal "ABC", @offline_group.name
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
offline_test "can upload down mirror files" do
|
84
|
-
mirror_data = ""
|
85
|
-
in_online_app do
|
86
|
-
GlobalRecord.create!(:title => "123")
|
87
|
-
get :download_down_mirror, "id" => @offline_group.id
|
88
|
-
mirror_data = @response.binary_content
|
89
|
-
end
|
90
|
-
|
91
|
-
in_offline_app do
|
92
|
-
assert_equal 0, GlobalRecord.count
|
93
|
-
post :upload_down_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
94
|
-
assert_response :success
|
95
|
-
assert_equal 1, GlobalRecord.count
|
96
|
-
assert_equal "123", GlobalRecord.first.title
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
cross_test "can upload initial down mirror files" do
|
101
|
-
mirror_data = ""
|
102
|
-
in_online_app do
|
103
|
-
get :download_initial_down_mirror, "id" => @offline_group.id
|
104
|
-
mirror_data = @response.binary_content
|
105
|
-
end
|
106
|
-
|
107
|
-
in_offline_app(false, true) do
|
108
|
-
assert_equal 0, Group.count
|
109
|
-
post :upload_initial_down_mirror, "mirror_data" => mirror_data
|
110
|
-
assert_equal 1, Group.count
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
offline_test "cannot retrieve down mirror files" do
|
115
|
-
assert_raise Offroad::PluginError do
|
116
|
-
get :download_down_mirror, {"id" => @offline_group.id}
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
offline_test "cannot upload up mirror files" do
|
121
|
-
get :download_up_mirror, "id" => @offline_group.id
|
122
|
-
mirror_data = @response.binary_content
|
123
|
-
|
124
|
-
assert_raise Offroad::PluginError do
|
125
|
-
post :upload_up_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
online_test "cannot upload down mirror files" do
|
130
|
-
get :download_down_mirror, "id" => @offline_group.id
|
131
|
-
mirror_data = @response.binary_content
|
132
|
-
|
133
|
-
assert_raise Offroad::PluginError do
|
134
|
-
post :upload_down_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
cross_test "cannot upload a mirror file for an online group" do
|
139
|
-
mirror_data = ""
|
140
|
-
in_offline_app do
|
141
|
-
get :download_up_mirror, "id" => @offline_group.id
|
142
|
-
mirror_data = @response.binary_content
|
143
|
-
end
|
144
|
-
|
145
|
-
in_online_app do
|
146
|
-
@offline_group.group_offline = false
|
147
|
-
assert_raise Offroad::PluginError do
|
148
|
-
post :upload_up_mirror, "id" => @online_group.id, "mirror_data" => mirror_data
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
# This just tests the controller's ability to properly access the functionality of the MirrorData class
|
4
|
+
# Tests for the actual generation and processing of mirror files are in mirror_data_test.rb
|
5
|
+
|
6
|
+
class GroupControllerTest < ActionController::TestCase
|
7
|
+
online_test "can retrieve a down mirror file for the offline group" do
|
8
|
+
get :download_down_mirror, "id" => @offline_group.id
|
9
|
+
assert_response :success
|
10
|
+
assert @response.headers["Content-Disposition"].include?("attachment")
|
11
|
+
content = @response.binary_content
|
12
|
+
assert content.include?("downloaded from the Test App online system"), "testapp's down mirror view file used"
|
13
|
+
|
14
|
+
StringIO.open(content) do |sio|
|
15
|
+
cs = Offroad::CargoStreamer.new(sio, "r")
|
16
|
+
mirror_info = cs.first_cargo_element("mirror_info")
|
17
|
+
assert mirror_info.app_mode.downcase.include?("online")
|
18
|
+
assert_equal false, mirror_info.initial_file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
online_test "can retrieve an initial down mirror file for the offline group" do
|
23
|
+
get :download_initial_down_mirror, "id" => @offline_group.id
|
24
|
+
assert_response :success
|
25
|
+
assert @response.headers["Content-Disposition"].include?("attachment")
|
26
|
+
content = @response.binary_content
|
27
|
+
assert content.include?("downloaded from the Test App online system"), "testapp's down mirror view file used"
|
28
|
+
|
29
|
+
StringIO.open(content) do |sio|
|
30
|
+
cs = Offroad::CargoStreamer.new(sio, "r")
|
31
|
+
mirror_info = cs.first_cargo_element("mirror_info")
|
32
|
+
assert mirror_info.app_mode.downcase.include?("online")
|
33
|
+
assert mirror_info.initial_file
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
offline_test "can retrieve an up mirror file for the offline group" do
|
38
|
+
get :download_up_mirror, "id" => @offline_group.id
|
39
|
+
assert_response :success
|
40
|
+
assert @response.headers["Content-Disposition"].include?("attachment")
|
41
|
+
content = @response.binary_content
|
42
|
+
assert content.include?("to the Test App online system"), "testapp's up mirror view file was used"
|
43
|
+
|
44
|
+
# This tests ViewHelper::link_to_online_app, used from the testapp's up mirror view
|
45
|
+
assert content.include?(">" + Offroad::online_url + "</a>")
|
46
|
+
assert content.include?("href=\"" + Offroad::online_url + "\"")
|
47
|
+
|
48
|
+
StringIO.open(content) do |sio|
|
49
|
+
cs = Offroad::CargoStreamer.new(sio, "r")
|
50
|
+
assert cs.first_cargo_element("mirror_info").app_mode.downcase.include?("offline")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
online_test "cannot retrieve up mirror files" do
|
55
|
+
assert_raise Offroad::PluginError do
|
56
|
+
get :download_up_mirror, "id" => @offline_group.id
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
online_test "cannot retrieve down mirror files for online groups" do
|
61
|
+
assert_raise Offroad::PluginError do
|
62
|
+
get :download_down_mirror, "id" => @online_group.id
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
cross_test "can upload up mirror files" do
|
67
|
+
mirror_data = ""
|
68
|
+
in_offline_app do
|
69
|
+
@offline_group.name = "ABC"
|
70
|
+
@offline_group.save!
|
71
|
+
get :download_up_mirror, "id" => @offline_group.id
|
72
|
+
mirror_data = @response.binary_content
|
73
|
+
end
|
74
|
+
|
75
|
+
in_online_app do
|
76
|
+
post :upload_up_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
77
|
+
assert_response :success
|
78
|
+
@offline_group.reload
|
79
|
+
assert_equal "ABC", @offline_group.name
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
offline_test "can upload down mirror files" do
|
84
|
+
mirror_data = ""
|
85
|
+
in_online_app do
|
86
|
+
GlobalRecord.create!(:title => "123")
|
87
|
+
get :download_down_mirror, "id" => @offline_group.id
|
88
|
+
mirror_data = @response.binary_content
|
89
|
+
end
|
90
|
+
|
91
|
+
in_offline_app do
|
92
|
+
assert_equal 0, GlobalRecord.count
|
93
|
+
post :upload_down_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
94
|
+
assert_response :success
|
95
|
+
assert_equal 1, GlobalRecord.count
|
96
|
+
assert_equal "123", GlobalRecord.first.title
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
cross_test "can upload initial down mirror files" do
|
101
|
+
mirror_data = ""
|
102
|
+
in_online_app do
|
103
|
+
get :download_initial_down_mirror, "id" => @offline_group.id
|
104
|
+
mirror_data = @response.binary_content
|
105
|
+
end
|
106
|
+
|
107
|
+
in_offline_app(false, true) do
|
108
|
+
assert_equal 0, Group.count
|
109
|
+
post :upload_initial_down_mirror, "mirror_data" => mirror_data
|
110
|
+
assert_equal 1, Group.count
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
offline_test "cannot retrieve down mirror files" do
|
115
|
+
assert_raise Offroad::PluginError do
|
116
|
+
get :download_down_mirror, {"id" => @offline_group.id}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
offline_test "cannot upload up mirror files" do
|
121
|
+
get :download_up_mirror, "id" => @offline_group.id
|
122
|
+
mirror_data = @response.binary_content
|
123
|
+
|
124
|
+
assert_raise Offroad::PluginError do
|
125
|
+
post :upload_up_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
online_test "cannot upload down mirror files" do
|
130
|
+
get :download_down_mirror, "id" => @offline_group.id
|
131
|
+
mirror_data = @response.binary_content
|
132
|
+
|
133
|
+
assert_raise Offroad::PluginError do
|
134
|
+
post :upload_down_mirror, "id" => @offline_group.id, "mirror_data" => mirror_data
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
cross_test "cannot upload a mirror file for an online group" do
|
139
|
+
mirror_data = ""
|
140
|
+
in_offline_app do
|
141
|
+
get :download_up_mirror, "id" => @offline_group.id
|
142
|
+
mirror_data = @response.binary_content
|
143
|
+
end
|
144
|
+
|
145
|
+
in_online_app do
|
146
|
+
@offline_group.group_offline = false
|
147
|
+
assert_raise Offroad::PluginError do
|
148
|
+
post :upload_up_mirror, "id" => @online_group.id, "mirror_data" => mirror_data
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|