advertnet 1.0.0
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 -0
- data/README +257 -0
- data/Rakefile +10 -0
- data/app/controllers/application.rb +40 -0
- data/app/controllers/container_controller.rb +83 -0
- data/app/controllers/content_controller.rb +61 -0
- data/app/controllers/furnitures_controller.rb +87 -0
- data/app/controllers/networks_controller.rb +269 -0
- data/app/controllers/objects_in_world_controller.rb +27 -0
- data/app/controllers/panels_controller.rb +186 -0
- data/app/helpers/application_helper.rb +31 -0
- data/app/helpers/container_helper.rb +2 -0
- data/app/helpers/content_helper.rb +2 -0
- data/app/helpers/furnitures_helper.rb +2 -0
- data/app/helpers/network_helper.rb +2 -0
- data/app/helpers/networks_helper.rb +2 -0
- data/app/helpers/objects_in_world_helper.rb +2 -0
- data/app/helpers/panels_helper.rb +2 -0
- data/app/models/container.rb +51 -0
- data/app/models/furniture.rb +60 -0
- data/app/models/mailer.rb +22 -0
- data/app/models/network.rb +38 -0
- data/app/models/object_in_world.rb +60 -0
- data/app/models/object_off_world.rb +77 -0
- data/app/models/panel.rb +136 -0
- data/app/models/panel_revision.rb +108 -0
- data/app/views/container/list.rhtml +27 -0
- data/app/views/container/show.rhtml +8 -0
- data/app/views/content/_form.rhtml +12 -0
- data/app/views/content/edit.rhtml +8 -0
- data/app/views/content/list.rhtml +26 -0
- data/app/views/content/new.rhtml +8 -0
- data/app/views/furnitures/list.rhtml +51 -0
- data/app/views/furnitures/show.rhtml +7 -0
- data/app/views/layouts/default.rhtml +30 -0
- data/app/views/mailer/avtouch.rhtml +1 -0
- data/app/views/networks/_form.rhtml +11 -0
- data/app/views/networks/_parameters_form.rhtml +8 -0
- data/app/views/networks/edit.rhtml +9 -0
- data/app/views/networks/list.rhtml +25 -0
- data/app/views/networks/new.rhtml +8 -0
- data/app/views/networks/show.rhtml +72 -0
- data/app/views/networks/show_parameters_form.rjs +5 -0
- data/app/views/objects_in_world/list.rhtml +30 -0
- data/app/views/objects_in_world/show.rhtml +8 -0
- data/app/views/panels/list.rhtml +48 -0
- data/app/views/panels/show.rhtml +8 -0
- data/bin/advertnet-install +144 -0
- data/config/boot.rb +45 -0
- data/config/database.yml.default +43 -0
- data/config/environment.rb +67 -0
- data/config/environments/development.rb +21 -0
- data/config/environments/production.rb +21 -0
- data/config/environments/test.rb +19 -0
- data/config/routes.rb +23 -0
- data/db/migrate/001_create_networks.rb +14 -0
- data/db/migrate/002_create_furnitures.rb +17 -0
- data/db/migrate/003_create_containers.rb +16 -0
- data/db/migrate/004_create_objects_in_world.rb +16 -0
- data/db/migrate/005_create_objects_off_world.rb +16 -0
- data/db/migrate/006_create_panels.rb +17 -0
- data/db/migrate/007_join_objects_in_world_panels.rb +17 -0
- data/db/migrate/008_join_objects_off_world_panels.rb +17 -0
- data/db/migrate/009_add_sessions.rb +19 -0
- data/db/migrate/010_add_or_rename_fields.rb +25 -0
- data/db/migrate/011_move_texture_to_object_in_world.rb +25 -0
- data/db/migrate/012_add_permanent_furniture_id.rb +18 -0
- data/db/migrate/013_create_panel_revisions.rb +42 -0
- data/db/schema.rb +102 -0
- data/doc/README_FOR_APP +108 -0
- data/lib/advertnet.rb +13 -0
- data/lib/second_life_validators.rb +89 -0
- data/lib/tasks/documentation.rake +16 -0
- data/lib/tasks/extract_fixtures.rake +23 -0
- data/lib/tasks/load_exported_fixtures.rake +14 -0
- data/public/404.html +30 -0
- data/public/500.html +30 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +24 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/images/rails.png +0 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/controls.js +833 -0
- data/public/javascripts/dragdrop.js +942 -0
- data/public/javascripts/effects.js +1088 -0
- data/public/javascripts/prototype.js +2515 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/application.css +25 -0
- data/public/stylesheets/scaffold.css +74 -0
- data/script/about +3 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/plugin +3 -0
- data/script/process/inspector +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/test/fixtures/containers.yml +44 -0
- data/test/fixtures/furnitures.yml +47 -0
- data/test/fixtures/mailer/avtouch +1 -0
- data/test/fixtures/networks.yml +31 -0
- data/test/fixtures/objects_in_world.yml +71 -0
- data/test/fixtures/objects_in_world_panels.yml +43 -0
- data/test/fixtures/objects_off_world.yml +55 -0
- data/test/fixtures/objects_off_world_panels.yml +20 -0
- data/test/fixtures/panel_revisions.yml +28 -0
- data/test/fixtures/panels.yml +79 -0
- data/test/functional/container_controller_test.rb +167 -0
- data/test/functional/content_controller_test.rb +91 -0
- data/test/functional/furnitures_controller_test.rb +134 -0
- data/test/functional/networks_controller_test.rb +248 -0
- data/test/functional/objects_in_world_controller_test.rb +42 -0
- data/test/functional/panels_controller_test.rb +173 -0
- data/test/test_helper.rb +53 -0
- data/test/unit/container_test.rb +53 -0
- data/test/unit/furniture_test.rb +68 -0
- data/test/unit/mailer_test.rb +40 -0
- data/test/unit/network_test.rb +42 -0
- data/test/unit/object_in_world_test.rb +33 -0
- data/test/unit/object_off_world_test.rb +26 -0
- data/test/unit/panel_revision_test.rb +148 -0
- data/test/unit/panel_test.rb +63 -0
- data/vendor/plugins/annotate_models/ChangeLog +46 -0
- data/vendor/plugins/annotate_models/README +31 -0
- data/vendor/plugins/annotate_models/lib/annotate_models.rb +132 -0
- data/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake +7 -0
- data/vendor/plugins/foreign_key_migrations/CHANGELOG +99 -0
- data/vendor/plugins/foreign_key_migrations/MIT-LICENSE +20 -0
- data/vendor/plugins/foreign_key_migrations/README +87 -0
- data/vendor/plugins/foreign_key_migrations/about.yml +5 -0
- data/vendor/plugins/foreign_key_migrations/init.rb +3 -0
- data/vendor/plugins/foreign_key_migrations/install.rb +1 -0
- data/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/base.rb +22 -0
- data/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/connection_adapters/abstract_adapter.rb +22 -0
- data/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/connection_adapters/table_definition.rb +28 -0
- data/vendor/plugins/redhillonrails_core/CHANGELOG +154 -0
- data/vendor/plugins/redhillonrails_core/MIT-LICENSE +20 -0
- data/vendor/plugins/redhillonrails_core/README +139 -0
- data/vendor/plugins/redhillonrails_core/init.rb +19 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb +54 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/abstract_adapter.rb +31 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/column.rb +21 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/foreign_key_definition.rb +26 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/index_definition.rb +11 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/mysql_adapter.rb +82 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/mysql_column.rb +8 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/postgresql_adapter.rb +107 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/schema_statements.rb +23 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/sqlite3_adapter.rb +9 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb +27 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema.rb +27 -0
- data/vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema_dumper.rb +47 -0
- metadata +290 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
|
2
|
+
# Association de l'URL "crao" (id 3) et de la Media URL "Glop media" (id 5) aux panneaux du réseau 1.
|
|
3
|
+
objects_off_world_panels_003:
|
|
4
|
+
object_off_world_id: "3"
|
|
5
|
+
panel_id: "5"
|
|
6
|
+
objects_off_world_panels_004:
|
|
7
|
+
object_off_world_id: "5"
|
|
8
|
+
panel_id: "1"
|
|
9
|
+
objects_off_world_panels_005:
|
|
10
|
+
object_off_world_id: "5"
|
|
11
|
+
panel_id: "3"
|
|
12
|
+
objects_off_world_panels_006:
|
|
13
|
+
object_off_world_id: "5"
|
|
14
|
+
panel_id: "5"
|
|
15
|
+
objects_off_world_panels_001:
|
|
16
|
+
object_off_world_id: "3"
|
|
17
|
+
panel_id: "1"
|
|
18
|
+
objects_off_world_panels_002:
|
|
19
|
+
object_off_world_id: "3"
|
|
20
|
+
panel_id: "3"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# == Schema Information
|
|
2
|
+
# Schema version: 13
|
|
3
|
+
#
|
|
4
|
+
# Table name: panel_revisions
|
|
5
|
+
#
|
|
6
|
+
# permanent_id :integer(11)
|
|
7
|
+
# panel_name :string(64) not null
|
|
8
|
+
# panel_key :string(36) not null
|
|
9
|
+
# furniture_name :string(64) not null
|
|
10
|
+
# furniture_key :string(36) not null
|
|
11
|
+
# network_name :string(64)
|
|
12
|
+
# network_status :boolean(1)
|
|
13
|
+
# texture_name :string(64) not null
|
|
14
|
+
# texture_key :string(36) not null
|
|
15
|
+
# landmark_name :string(64)
|
|
16
|
+
# landmark_key :string(36)
|
|
17
|
+
# notecard_name :string(64)
|
|
18
|
+
# notecard_key :string(36)
|
|
19
|
+
# url_name :string(64)
|
|
20
|
+
# url_content :text
|
|
21
|
+
# mediaurl_name :string(64)
|
|
22
|
+
# mediaurl_content :text
|
|
23
|
+
# sim :string(64) not null
|
|
24
|
+
# position :string(40) not null
|
|
25
|
+
# created_at :datetime
|
|
26
|
+
#
|
|
27
|
+
|
|
28
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# == Schema Information
|
|
2
|
+
# Schema version: 13
|
|
3
|
+
#
|
|
4
|
+
# Table name: panels
|
|
5
|
+
#
|
|
6
|
+
# id :integer(11) not null, primary key
|
|
7
|
+
# name :string(64) not null
|
|
8
|
+
# panel_key :string(36) not null
|
|
9
|
+
# furniture_id :integer(11) not null
|
|
10
|
+
# network_id :integer(11)
|
|
11
|
+
# created_at :datetime
|
|
12
|
+
# updated_at :datetime
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
|
16
|
+
panel1_furniture1:
|
|
17
|
+
furniture_id: "1"
|
|
18
|
+
name: B1
|
|
19
|
+
updated_at: 2007-08-15 17:37:27
|
|
20
|
+
network_id: 1
|
|
21
|
+
id: "1"
|
|
22
|
+
created_at: 2007-08-15 17:37:27
|
|
23
|
+
panel_key: 2eb21eff-a377-2170-fb78-83f8b15ea9df
|
|
24
|
+
panel2_furniture1:
|
|
25
|
+
furniture_id: "1"
|
|
26
|
+
name: B2
|
|
27
|
+
updated_at: 2007-08-15 17:41:28
|
|
28
|
+
network_id: 2
|
|
29
|
+
id: "2"
|
|
30
|
+
created_at: 2007-08-15 17:41:28
|
|
31
|
+
panel_key: 358d2e76-ab14-3837-244c-ab533d781d52
|
|
32
|
+
panel3_furniture1:
|
|
33
|
+
furniture_id: "1"
|
|
34
|
+
name: B3
|
|
35
|
+
updated_at: 2007-08-15 17:42:13
|
|
36
|
+
network_id: 1
|
|
37
|
+
id: "3"
|
|
38
|
+
created_at: 2007-08-15 17:42:13
|
|
39
|
+
panel_key: f82eff9a-b2b9-4592-21c0-17aee3abe002
|
|
40
|
+
panel4_furniture1:
|
|
41
|
+
furniture_id: "1"
|
|
42
|
+
name: B4
|
|
43
|
+
updated_at: 2007-08-15 17:42:56
|
|
44
|
+
network_id:
|
|
45
|
+
id: "4"
|
|
46
|
+
created_at: 2007-08-15 17:42:53
|
|
47
|
+
panel_key: d58ea47c-36df-5fd9-7469-23674c00b226
|
|
48
|
+
panel1_furniture2:
|
|
49
|
+
furniture_id: "7"
|
|
50
|
+
name: B1
|
|
51
|
+
updated_at: 2007-08-15 17:43:59
|
|
52
|
+
network_id: 1
|
|
53
|
+
id: "5"
|
|
54
|
+
created_at: 2007-08-15 17:43:59
|
|
55
|
+
panel_key: 914897fb-b422-8cb7-3342-b0bbb292e91e
|
|
56
|
+
panel2_furniture2:
|
|
57
|
+
furniture_id: "7"
|
|
58
|
+
name: B2
|
|
59
|
+
updated_at: 2007-08-15 17:44:17
|
|
60
|
+
network_id: 2
|
|
61
|
+
id: "6"
|
|
62
|
+
created_at: 2007-08-15 17:44:17
|
|
63
|
+
panel_key: 1d2cd825-74ef-70d8-e70d-3030e0d3b0cc
|
|
64
|
+
panel1_furniture3:
|
|
65
|
+
furniture_id: "3"
|
|
66
|
+
name: B1
|
|
67
|
+
updated_at: 2007-08-15 17:44:43
|
|
68
|
+
network_id: 2
|
|
69
|
+
id: "7"
|
|
70
|
+
created_at: 2007-08-15 17:44:43
|
|
71
|
+
panel_key: 897c6c72-58a0-e734-6a51-c00b200f30ec
|
|
72
|
+
panel2_furniture3:
|
|
73
|
+
furniture_id: "3"
|
|
74
|
+
name: B2
|
|
75
|
+
updated_at: 2007-08-15 17:44:56
|
|
76
|
+
network_id:
|
|
77
|
+
id: "8"
|
|
78
|
+
created_at: 2007-08-15 17:44:56
|
|
79
|
+
panel_key: 20fbf8bf-c95f-64a5-17b7-a41bdf99e0ba
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'container_controller'
|
|
3
|
+
|
|
4
|
+
# Re-raise errors caught by the controller.
|
|
5
|
+
class ContainerController; def rescue_action(e) raise e end; end
|
|
6
|
+
|
|
7
|
+
class ContainerControllerTest < Test::Unit::TestCase
|
|
8
|
+
fixtures :containers, :objects_in_world
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@controller = ContainerController.new
|
|
12
|
+
@request = ActionController::TestRequest.new
|
|
13
|
+
@response = ActionController::TestResponse.new
|
|
14
|
+
|
|
15
|
+
@first_id = containers(:container_1).id
|
|
16
|
+
@empty_id = containers(:container_empty).id
|
|
17
|
+
|
|
18
|
+
@content_texture = [
|
|
19
|
+
"Texture 1", "02cfbe85-b6ab-6a1f-24e1-42addb619498",
|
|
20
|
+
"Texture 2", "9557ee31-8939-1dfb-36db-706443241b6e",
|
|
21
|
+
"Texture 3", "0140bc84-2946-95a7-a5b6-c4ad09f20a50"
|
|
22
|
+
]
|
|
23
|
+
@content_misc = [
|
|
24
|
+
"Landmark 1", "95090411-33d9-563a-b404-e07403ccacb3", "landmark",
|
|
25
|
+
"Notecard 1", "b1582b34-2f74-eb7d-f468-1986ba2da8a4" "notecard"
|
|
26
|
+
]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Construit une chaîne d'objet dans laquelle "nom" et "clé" sont séparés
|
|
30
|
+
# par des "|", et les enregistrements ainsi formés sont séparés par des ","
|
|
31
|
+
def object_array_to_string(ary, column_count)
|
|
32
|
+
ary.in_groups_of(column_count).collect { |r| r.join("|")}.join(",")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_register_new_container
|
|
36
|
+
assert_nil Container.find_by_container_key("d906e900-708f-fd93-8245-79000494711e")
|
|
37
|
+
container_count = Container.count
|
|
38
|
+
content_string = object_array_to_string(@content_texture, 2)
|
|
39
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_KEY"] = "d906e900-708f-fd93-8245-79000494711e"
|
|
40
|
+
@request.env["HTTP_X_SECONDLIFE_REGION"] = "Myeon (263936, 235008)"
|
|
41
|
+
@request.env["HTTP_X_SECONDLIFE_LOCAL_POSITION"] = "(33.413044, 2.188796, 136.624924)"
|
|
42
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_NAME"] = "Container Test"
|
|
43
|
+
post :register, :content => content_string
|
|
44
|
+
assert_response :success
|
|
45
|
+
assert_template nil
|
|
46
|
+
assert_equal container_count + 1, Container.count
|
|
47
|
+
assert_nothing_raised {
|
|
48
|
+
@container = Container.find_by_container_key("d906e900-708f-fd93-8245-79000494711e")
|
|
49
|
+
}
|
|
50
|
+
assert_equal 3, @container.objects_in_world.count
|
|
51
|
+
objects = @container.objects_in_world
|
|
52
|
+
objects.each { |o|
|
|
53
|
+
assert @content_texture.include?(o.object_key)
|
|
54
|
+
assert @content_texture.include?(o.name)
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_register_and_update_container
|
|
59
|
+
container_count = Container.count
|
|
60
|
+
content_string = object_array_to_string(@content_texture, 2)
|
|
61
|
+
# Première fois
|
|
62
|
+
assert_nil Container.find_by_container_key("d906e900-708f-fd93-8245-79000494711e")
|
|
63
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_KEY"] = "d906e900-708f-fd93-8245-79000494711e"
|
|
64
|
+
@request.env["HTTP_X_SECONDLIFE_REGION"] = "Myeon (263936, 235008)"
|
|
65
|
+
@request.env["HTTP_X_SECONDLIFE_LOCAL_POSITION"] = "(33.413044, 2.188796, 136.624924)"
|
|
66
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_NAME"] = "Container Test"
|
|
67
|
+
post :register, :content => content_string
|
|
68
|
+
assert_response :success
|
|
69
|
+
assert_template nil
|
|
70
|
+
assert_equal container_count + 1, Container.count
|
|
71
|
+
assert_nothing_raised {
|
|
72
|
+
@container = Container.find_by_container_key("d906e900-708f-fd93-8245-79000494711e")
|
|
73
|
+
}
|
|
74
|
+
assert_equal "Myeon", @container.sim
|
|
75
|
+
assert_equal "33,2,136", @container.position
|
|
76
|
+
assert_equal "Container Test", @container.name
|
|
77
|
+
assert_equal 3, @container.objects_in_world.count
|
|
78
|
+
objects = @container.objects_in_world
|
|
79
|
+
objects.each { |o|
|
|
80
|
+
assert @content_texture.include?(o.object_key)
|
|
81
|
+
assert @content_texture.include?(o.name)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Deuxième fois, on change légèrement certains attributs
|
|
85
|
+
# et on enlève un objet
|
|
86
|
+
content_smaller = @content_texture[0..-3]
|
|
87
|
+
content_string = object_array_to_string(content_smaller, 2)
|
|
88
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_KEY"] = "d906e900-708f-fd93-8245-79000494711e"
|
|
89
|
+
@request.env["HTTP_X_SECONDLIFE_REGION"] = "Myeon (263936, 235008)"
|
|
90
|
+
@request.env["HTTP_X_SECONDLIFE_LOCAL_POSITION"] = "(66.413044, 200.188796, 236.624924)"
|
|
91
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_NAME"] = "Container Test 2"
|
|
92
|
+
post :register, :content => content_string
|
|
93
|
+
assert_response :success
|
|
94
|
+
assert_template nil
|
|
95
|
+
assert_equal container_count + 1, Container.count
|
|
96
|
+
assert_nothing_raised {
|
|
97
|
+
@container = Container.find_by_container_key("d906e900-708f-fd93-8245-79000494711e")
|
|
98
|
+
}
|
|
99
|
+
assert_equal "Myeon", @container.sim
|
|
100
|
+
assert_equal "66,200,236", @container.position
|
|
101
|
+
assert_equal "Container Test 2", @container.name
|
|
102
|
+
assert_equal 2, @container.objects_in_world.count
|
|
103
|
+
objects = @container.objects_in_world
|
|
104
|
+
objects.each { |o|
|
|
105
|
+
assert content_smaller.include?(o.object_key)
|
|
106
|
+
assert content_smaller.include?(o.name)
|
|
107
|
+
}
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_index
|
|
111
|
+
get :index
|
|
112
|
+
assert_response :success
|
|
113
|
+
assert_template 'list'
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_list
|
|
117
|
+
get :list
|
|
118
|
+
|
|
119
|
+
assert_response :success
|
|
120
|
+
assert_template 'list'
|
|
121
|
+
|
|
122
|
+
assert_not_nil assigns(:containers)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_show
|
|
126
|
+
get :show, :id => @first_id
|
|
127
|
+
|
|
128
|
+
assert_response :success
|
|
129
|
+
assert_template 'show'
|
|
130
|
+
|
|
131
|
+
assert_not_nil assigns(:container)
|
|
132
|
+
assert assigns(:container).valid?
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_destroy_empty_container
|
|
136
|
+
assert_nothing_raised {
|
|
137
|
+
@container_empty = Container.find(@empty_id)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
assert @container_empty.objects_in_world.empty?
|
|
141
|
+
|
|
142
|
+
post :destroy, :id => @empty_id
|
|
143
|
+
assert_response :redirect
|
|
144
|
+
assert_redirected_to :action => 'list'
|
|
145
|
+
|
|
146
|
+
assert_raise(ActiveRecord::RecordNotFound) {
|
|
147
|
+
Container.find(@empty_id)
|
|
148
|
+
}
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def test_destroy_full_container
|
|
152
|
+
assert_nothing_raised {
|
|
153
|
+
@container_full = Container.find(@first_id)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
assert !@container_full.objects_in_world.empty?
|
|
157
|
+
|
|
158
|
+
post :destroy, :id => @first_id
|
|
159
|
+
assert_response 409
|
|
160
|
+
assert_template nil
|
|
161
|
+
assert_equal "Cannot delete a non-empty container.", @response.body
|
|
162
|
+
|
|
163
|
+
assert_nothing_raised {
|
|
164
|
+
Container.find(@first_id)
|
|
165
|
+
}
|
|
166
|
+
end
|
|
167
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'content_controller'
|
|
3
|
+
|
|
4
|
+
# Re-raise errors caught by the controller.
|
|
5
|
+
class ContentController; def rescue_action(e) raise e end; end
|
|
6
|
+
|
|
7
|
+
class ContentControllerTest < Test::Unit::TestCase
|
|
8
|
+
fixtures :objects_off_world
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@controller = ContentController.new
|
|
12
|
+
@request = ActionController::TestRequest.new
|
|
13
|
+
@response = ActionController::TestResponse.new
|
|
14
|
+
|
|
15
|
+
@first_id = objects_off_world(:lacoste).id
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_index
|
|
19
|
+
get :index
|
|
20
|
+
assert_response :success
|
|
21
|
+
assert_template 'list'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_list
|
|
25
|
+
get :list
|
|
26
|
+
|
|
27
|
+
assert_response :success
|
|
28
|
+
assert_template 'list'
|
|
29
|
+
|
|
30
|
+
assert_not_nil assigns(:objects_off_world)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_new
|
|
34
|
+
get :new
|
|
35
|
+
|
|
36
|
+
assert_response :success
|
|
37
|
+
assert_template 'new'
|
|
38
|
+
|
|
39
|
+
assert_not_nil assigns(:object_off_world)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_create
|
|
43
|
+
num_objects_off_world = ObjectOffWorld.count
|
|
44
|
+
|
|
45
|
+
post :create, :object_off_world => { :name => "my url", :otype => "url", :content => "http://www.my.url"}
|
|
46
|
+
|
|
47
|
+
assert_response :redirect
|
|
48
|
+
assert_redirected_to :action => 'list'
|
|
49
|
+
|
|
50
|
+
assert_equal num_objects_off_world + 1, ObjectOffWorld.count
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_edit
|
|
54
|
+
get :edit, :id => @first_id
|
|
55
|
+
|
|
56
|
+
assert_response :success
|
|
57
|
+
assert_template 'edit'
|
|
58
|
+
|
|
59
|
+
assert_not_nil assigns(:object_off_world)
|
|
60
|
+
assert assigns(:object_off_world).valid?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_update
|
|
64
|
+
post :update, :id => @first_id, :object_off_world => { :name => "my url", :otype => "url", :content => "http://www.my.url"}
|
|
65
|
+
assert_response :redirect
|
|
66
|
+
assert_redirected_to :action => 'list'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_update_failed
|
|
70
|
+
post :update, :id => @first_id, :object_off_world => { :name => "my glop", :otype => "GLOP", :content => "Glop"}
|
|
71
|
+
assert_response :success
|
|
72
|
+
assert_template 'edit'
|
|
73
|
+
|
|
74
|
+
assert_not_nil assigns(:object_off_world)
|
|
75
|
+
assert !assigns(:object_off_world).valid?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_destroy
|
|
79
|
+
assert_nothing_raised {
|
|
80
|
+
ObjectOffWorld.find(@first_id)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
post :destroy, :id => @first_id
|
|
84
|
+
assert_response :redirect
|
|
85
|
+
assert_redirected_to :action => 'list'
|
|
86
|
+
|
|
87
|
+
assert_raise(ActiveRecord::RecordNotFound) {
|
|
88
|
+
ObjectOffWorld.find(@first_id)
|
|
89
|
+
}
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'furnitures_controller'
|
|
3
|
+
|
|
4
|
+
# Re-raise errors caught by the controller.
|
|
5
|
+
class FurnituresController; def rescue_action(e) raise e end; end
|
|
6
|
+
|
|
7
|
+
class FurnituresControllerTest < Test::Unit::TestCase
|
|
8
|
+
fixtures :furnitures
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@controller = FurnituresController.new
|
|
12
|
+
@request = ActionController::TestRequest.new
|
|
13
|
+
@response = ActionController::TestResponse.new
|
|
14
|
+
|
|
15
|
+
@first_id = furnitures(:furniture_1).id
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Met en variables d'environnement les paramètres SL de l'objet appelant
|
|
19
|
+
# quand on teste une URL appelée par SL.
|
|
20
|
+
def setup_sl_env
|
|
21
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_KEY"] = "d906e900-708f-fd93-8245-79000494711e"
|
|
22
|
+
@request.env["HTTP_X_SECONDLIFE_REGION"] = "Myeon (263936, 235008)"
|
|
23
|
+
@request.env["HTTP_X_SECONDLIFE_LOCAL_POSITION"] = "(33.413044, 2.188796, 136.624924)"
|
|
24
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_NAME"] = "Furniture Test"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_index
|
|
28
|
+
get :index
|
|
29
|
+
assert_response :success
|
|
30
|
+
assert_template 'list'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_list
|
|
34
|
+
get :list
|
|
35
|
+
|
|
36
|
+
assert_response :success
|
|
37
|
+
assert_template 'list'
|
|
38
|
+
|
|
39
|
+
assert_not_nil assigns(:furnitures)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_show
|
|
43
|
+
get :show, :id => @first_id
|
|
44
|
+
|
|
45
|
+
assert_response :success
|
|
46
|
+
assert_template 'show'
|
|
47
|
+
|
|
48
|
+
assert_not_nil assigns(:furniture)
|
|
49
|
+
assert assigns(:furniture).valid?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_register_missing_sl_env
|
|
53
|
+
furniture_count = Furniture.count
|
|
54
|
+
# On n'appelle pas 'setup_sl_env'
|
|
55
|
+
post :register
|
|
56
|
+
|
|
57
|
+
assert_response 409
|
|
58
|
+
assert_template nil
|
|
59
|
+
assert_equal "Missing Second Life environment", @response.body
|
|
60
|
+
assert_equal furniture_count, Furniture.count
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_register
|
|
64
|
+
furniture_count = Furniture.count
|
|
65
|
+
setup_sl_env
|
|
66
|
+
post :register
|
|
67
|
+
|
|
68
|
+
assert_response :success
|
|
69
|
+
assert_template nil
|
|
70
|
+
assert_match(/delay=30\npermanent_id=\d+\n/, @response.body)
|
|
71
|
+
assert_equal furniture_count+1, Furniture.count
|
|
72
|
+
assert_nothing_raised {
|
|
73
|
+
@furniture = Furniture.find_by_furniture_key("d906e900-708f-fd93-8245-79000494711e")
|
|
74
|
+
}
|
|
75
|
+
assert_equal "Furniture Test", @furniture.name
|
|
76
|
+
assert_equal "Myeon", @furniture.sim
|
|
77
|
+
assert_equal "33,2,136", @furniture.position
|
|
78
|
+
# On vérifie le permanent id
|
|
79
|
+
regex_permanent_id = /permanent_id=(\d+)\n/
|
|
80
|
+
match_data = regex_permanent_id.match(@response.body)
|
|
81
|
+
assert_not_nil match_data # On retrouve l'id de la réponse HTTP
|
|
82
|
+
assert_equal match_data[1].to_i, @furniture.permanent_id # et on le compare au mobilier créé
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_register_with_permanent_id
|
|
86
|
+
furniture_count = Furniture.count
|
|
87
|
+
setup_sl_env
|
|
88
|
+
permanent_id = 1000 + rand(100)
|
|
89
|
+
post :register, :permanent_id => permanent_id
|
|
90
|
+
|
|
91
|
+
assert_response :success
|
|
92
|
+
assert_template nil
|
|
93
|
+
assert_match(/delay=30\npermanent_id=#{permanent_id}\n/, @response.body)
|
|
94
|
+
assert_equal furniture_count+1, Furniture.count
|
|
95
|
+
assert_nothing_raised {
|
|
96
|
+
@furniture = Furniture.find_by_furniture_key("d906e900-708f-fd93-8245-79000494711e")
|
|
97
|
+
}
|
|
98
|
+
assert_equal "Furniture Test", @furniture.name
|
|
99
|
+
assert_equal "Myeon", @furniture.sim
|
|
100
|
+
assert_equal "33,2,136", @furniture.position
|
|
101
|
+
assert_equal permanent_id, @furniture.permanent_id
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_reregister
|
|
105
|
+
furniture_count = Furniture.count
|
|
106
|
+
|
|
107
|
+
# Premier enregistrement
|
|
108
|
+
setup_sl_env
|
|
109
|
+
post :register
|
|
110
|
+
|
|
111
|
+
assert_response :success
|
|
112
|
+
assert_template nil
|
|
113
|
+
assert_equal furniture_count+1, Furniture.count
|
|
114
|
+
assert_nothing_raised {
|
|
115
|
+
@furniture = Furniture.find_by_furniture_key("d906e900-708f-fd93-8245-79000494711e")
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# Mise à jour
|
|
119
|
+
@request.env["HTTP_X_SECONDLIFE_REGION"] = "Palace (263936, 235008)"
|
|
120
|
+
@request.env["HTTP_X_SECONDLIFE_LOCAL_POSITION"] = "(32.413044, 3.188796, 120.624924)"
|
|
121
|
+
@request.env["HTTP_X_SECONDLIFE_OBJECT_NAME"] = "Furniture Test 2"
|
|
122
|
+
post :register
|
|
123
|
+
|
|
124
|
+
assert_response :success
|
|
125
|
+
assert_template nil
|
|
126
|
+
assert_equal furniture_count+1, Furniture.count
|
|
127
|
+
assert_nothing_raised {
|
|
128
|
+
@furniture = Furniture.find_by_furniture_key("d906e900-708f-fd93-8245-79000494711e")
|
|
129
|
+
}
|
|
130
|
+
assert_equal "Furniture Test 2", @furniture.name
|
|
131
|
+
assert_equal "Palace", @furniture.sim
|
|
132
|
+
assert_equal "32,3,120", @furniture.position
|
|
133
|
+
end
|
|
134
|
+
end
|