zena 0.15.2 → 0.16.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/.gitignore +20 -0
- data/CREDITS +27 -0
- data/Capfile +3 -0
- data/DEVELOPERS +46 -0
- data/History.txt +15 -0
- data/MIT-LICENSE +19 -0
- data/Rakefile +44 -0
- data/TODO +24 -0
- data/TODO_ZENA_1_0 +23 -0
- data/app/controllers/application_controller.rb +3 -0
- data/app/controllers/documents_controller.rb +22 -56
- data/app/controllers/nodes_controller.rb +42 -27
- data/app/controllers/pings_controller.rb +19 -0
- data/app/controllers/relations_controller.rb +5 -1
- data/app/controllers/sites_controller.rb +1 -46
- data/app/controllers/user_sessions_controller.rb +47 -0
- data/app/controllers/users_controller.rb +1 -0
- data/app/controllers/versions_controller.rb +25 -7
- data/app/controllers/virtual_classes_controller.rb +1 -1
- data/app/helpers/application_helper.rb +1 -1
- data/app/models/comment.rb +2 -1
- data/app/models/contact_content.rb +2 -2
- data/app/models/data_entry.rb +5 -6
- data/app/models/document.rb +14 -10
- data/app/models/document_content.rb +4 -6
- data/app/models/iformat.rb +2 -2
- data/app/models/image_content.rb +6 -9
- data/app/models/node.rb +106 -164
- data/app/models/page.rb +0 -20
- data/app/models/site.rb +42 -12
- data/app/models/template.rb +3 -8
- data/app/models/template_content.rb +2 -0
- data/app/models/text_document.rb +13 -8
- data/app/models/user.rb +47 -100
- data/app/models/user_session.rb +4 -0
- data/app/models/version.rb +1 -1
- data/app/views/comments/create.rjs +3 -3
- data/app/views/comments/edit.rjs +1 -1
- data/app/views/comments/update.rjs +1 -1
- data/app/views/nodes/_import_results.rhtml +1 -1
- data/app/views/nodes/create.rjs +3 -3
- data/app/views/templates/document_create_tabs/_file.rhtml +1 -2
- data/app/views/templates/document_create_tabs/_import.rhtml +7 -2
- data/app/views/templates/edit_tabs/_document.rhtml +1 -3
- data/app/views/templates/edit_tabs/_image.rhtml +1 -3
- data/app/views/versions/_tr.rhtml +1 -1
- data/app/views/versions/edit.rhtml +2 -26
- data/bin/zena +6 -1
- data/bricks/delayed_job/README +18 -0
- data/bricks/delayed_job/migrate/20091104191643_create_delayed_jobs_table.rb +19 -0
- data/bricks/delayed_job/misc/init.rb +8 -0
- data/bricks/delayed_job/misc/tasks.rb +2 -0
- data/bricks/math/patch/application_helper.rb +1 -1
- data/bricks/sphinx/MIT-LICENSE +19 -0
- data/bricks/sphinx/README +19 -0
- data/bricks/sphinx/lib/use_sphinx.rb +78 -0
- data/bricks/sphinx/migrate/20091102171258_add_delta_for_sphinx.rb +9 -0
- data/bricks/sphinx/misc/deploy.rb +20 -0
- data/bricks/sphinx/misc/sphinx.yml +12 -0
- data/bricks/sphinx/misc/tasks.rb +21 -0
- data/bricks/sphinx/patch/node.rb +8 -0
- data/bricks/tags/lib/has_tags.rb +5 -3
- data/bricks/tags/test/zafu/tags.yml +13 -1
- data/config/bricks.yml +35 -0
- data/config/deploy.rb +8 -1
- data/config/environment.rb +1 -1
- data/config/environments/production.rb +1 -1
- data/config/gems.yml +28 -5
- data/config/sphinx.yml +12 -0
- data/db/init/base/skins/default/Node-+popupLayout.zafu +1 -16
- data/db/migrate/20091026161708_add_persistence_token.rb +13 -0
- data/db/migrate/20091101184952_add_session_table.rb +16 -0
- data/db/migrate/20091123175137_add_single_access_token.rb +9 -0
- data/db/migrate/20091124161608_rebuild_fullpath.rb +11 -0
- data/db/schema.rb +21 -8
- data/doc/README_FOR_APP +24 -0
- data/doc/fixtures.graffle +19568 -0
- data/doc/fixtures.pdf +0 -0
- data/doc/template/LICENSE +184 -0
- data/doc/template/README +37 -0
- data/doc/template/allison.css +283 -0
- data/doc/template/allison.js +307 -0
- data/doc/template/allison.rb +260 -0
- data/doc/template/cache/BODY +588 -0
- data/doc/template/cache/CLASS_INDEX +4 -0
- data/doc/template/cache/CLASS_PAGE +1 -0
- data/doc/template/cache/FILE_INDEX +4 -0
- data/doc/template/cache/FILE_PAGE +1 -0
- data/doc/template/cache/FONTS +1 -0
- data/doc/template/cache/FR_INDEX_BODY +1 -0
- data/doc/template/cache/IMGPATH +1 -0
- data/doc/template/cache/INDEX +1 -0
- data/doc/template/cache/JAVASCRIPT +307 -0
- data/doc/template/cache/METHOD_INDEX +4 -0
- data/doc/template/cache/METHOD_LIST +1 -0
- data/doc/template/cache/SRC_PAGE +1 -0
- data/doc/template/cache/STYLE +283 -0
- data/doc/template/cache/URL +1 -0
- data/doc/zafu_changes.yml +29 -0
- data/lib/base_additions.rb +1 -1
- data/lib/bricks.rb +9 -0
- data/lib/bricks/loader.rb +86 -0
- data/lib/bricks/requirements_validation.rb +71 -0
- data/lib/tasks/zena.rake +42 -4
- data/lib/zafu/action.rb +285 -0
- data/lib/zafu/ajax.rb +93 -0
- data/lib/zafu/attributes.rb +117 -0
- data/lib/zafu/calendar.rb +159 -0
- data/lib/zafu/context.rb +330 -0
- data/lib/zafu/core/html.rb +102 -0
- data/lib/zafu/core/move_to_parser.rb +167 -0
- data/lib/zafu/dates.rb +58 -0
- data/lib/zafu/display.rb +502 -0
- data/lib/zafu/eval.rb +66 -0
- data/lib/zafu/experimental.rb +66 -0
- data/lib/zafu/i18n.rb +64 -0
- data/lib/zafu/meta.rb +25 -0
- data/lib/zafu/refactor.rb +73 -0
- data/lib/zafu/support/context.rb +265 -0
- data/lib/zafu/support/dom.rb +145 -0
- data/lib/zafu/support/erb.rb +62 -0
- data/lib/zafu/support/flow.rb +401 -0
- data/lib/zafu/support/forms.rb +461 -0
- data/lib/zafu/support/links.rb +306 -0
- data/lib/zafu_parser.rb +26 -2
- data/lib/zena.rb +34 -15
- data/lib/zena/acts/multiversion.rb +2 -2
- data/lib/zena/acts/secure.rb +41 -30
- data/lib/zena/app.rb +7 -10
- data/lib/zena/controller/test_case.rb +12 -7
- data/lib/zena/crypto_provider/initial.rb +15 -0
- data/lib/zena/db.rb +6 -1
- data/lib/zena/deploy.rb +34 -6
- data/lib/zena/deploy/logrotate_app.rhtml +9 -0
- data/lib/zena/deploy/logrotate_host.rhtml +34 -0
- data/lib/zena/deploy/template.rb +1 -9
- data/lib/zena/foxy_parser.rb +1 -1
- data/lib/zena/info.rb +3 -1
- data/lib/zena/migrator.rb +1 -1
- data/lib/zena/parser.rb +12 -4
- data/lib/zena/parser/zazen_rules.rb +6 -6
- data/lib/zena/parser/zena_rules.rb +1 -7
- data/lib/zena/routes.rb +5 -5
- data/lib/zena/test_controller.rb +7 -2
- data/lib/zena/unit/test_case.rb +6 -8
- data/lib/zena/use/ajax.rb +10 -10
- data/lib/zena/use/authlogic.rb +93 -0
- data/lib/zena/use/dyn_attributes.rb +5 -0
- data/lib/zena/use/html_tags.rb +16 -34
- data/lib/zena/use/i18n.rb +4 -1
- data/lib/zena/use/node_query_finders.rb +8 -4
- data/lib/zena/use/refactor.rb +8 -20
- data/lib/zena/use/relations.rb +1 -0
- data/lib/zena/use/rendering.rb +4 -2
- data/lib/zena/use/search.rb +52 -0
- data/lib/zena/use/test_helper.rb +27 -28
- data/lib/zena/use/upload.rb +188 -0
- data/lib/zena/use/urls.rb +16 -14
- data/lib/zena/use/zafu.rb +16 -63
- data/lib/zena/use/zazen.rb +8 -8
- data/lib/zena/view/test_case.rb +8 -4
- data/locale/en/LC_MESSAGES/zena.mo +0 -0
- data/locale/en/zena.po +3 -3
- data/public/.htaccess +40 -0
- data/public/javascripts/upload-progress.js +17 -8
- data/public/javascripts/zena.js +8 -2
- data/public/stylesheets/popup.css +1 -0
- data/script/about +3 -0
- data/script/apache_logging +25 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/dbconsole +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/script/set_revision +29 -0
- data/spec/controllers/versions_controller_spec.rb +11 -0
- data/test/fixtures/files/Node-test.zafu +1 -1
- data/test/functional/nodes_controller_test.rb +25 -0
- data/test/functional/pings_controller_test.rb +8 -0
- data/test/functional/user_sessions_controller_test.rb +59 -0
- data/test/functional/users_controller_test.rb +81 -19
- data/test/helpers/node_query/filters.yml +5 -0
- data/test/helpers/node_query_test.rb +3 -3
- data/test/integration/multiple_hosts_test.rb +1 -1
- data/test/integration/navigation_test.rb +1 -1
- data/test/sites/complex/users.yml +1 -1
- data/test/sites/ocean/users.yml +3 -3
- data/test/sites/zena/users.yml +5 -4
- data/test/test_zena.rb +38 -38
- data/test/unit/cached_page_test.rb +2 -2
- data/test/unit/comment_test.rb +0 -1
- data/test/unit/document_test.rb +23 -11
- data/test/unit/helpers/ping_helper_test.rb +4 -0
- data/test/unit/multiversion_test.rb +24 -16
- data/test/unit/node_test.rb +32 -93
- data/test/unit/note_test.rb +9 -0
- data/test/unit/page_test.rb +2 -2
- data/test/unit/secure_test.rb +2 -12
- data/test/unit/site_test.rb +43 -24
- data/test/unit/template_test.rb +45 -3
- data/test/unit/text_document_test.rb +4 -3
- data/test/unit/user_test.rb +13 -33
- data/test/unit/zena/db_test.rb +8 -0
- data/test/unit/zena/parser/zazen.yml +4 -4
- data/test/unit/zena/use/dates_view_methods_test.rb +2 -1
- data/test/unit/zena/use/html_tags_test.rb +12 -4
- data/test/unit/zena/use/refactor_test.rb +4 -3
- data/test/unit/zena/use/rendering_test.rb +1 -0
- data/test/unit/zena/use/upload_test.rb +76 -0
- data/test/unit/zena/use/urls_test.rb +4 -0
- data/test/unit/zena/use/zafu_test.rb +8 -0
- data/test/unit/zena/workflow/status_version_test.rb +6 -0
- data/test/unit/zena/zena_tags/ajax.yml +4 -4
- data/test/unit/zena/zena_tags/basic.yml +21 -10
- data/test/unit/zena/zena_tags/relations.yml +0 -6
- data/test/unit/zena/zena_tags/rubyless.yml +35 -0
- data/test/unit/zena/zena_tags/zazen.yml +4 -4
- data/test/unit/zena/zena_tags_test.rb +36 -4
- data/vendor/TextMate/Zena.tmbundle/Commands/Run all yaml tests.tmCommand +1 -1
- data/vendor/TextMate/Zena.tmbundle/Commands/Run focused yaml test.tmCommand +2 -3
- data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/catch_exception.rb +39 -0
- data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/run_script.rb +102 -58
- data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/stdin_dialog.rb +14 -0
- data/vendor/TextMate/Zena.tmbundle/info.plist +2 -0
- data/zena.gemspec +2085 -0
- metadata +265 -90
- data/app/controllers/sessions_controller.rb +0 -41
- data/app/views/sites/zena_up.html.erb +0 -11
- data/config/database.yml +0 -40
- data/db/production.sqlite3 +0 -0
- data/lib/bricks/patcher.rb +0 -68
- data/lib/zena/parser/zena_tags.rb +0 -3562
- data/lib/zena/use/authentification.rb +0 -120
- data/public/images/ext/contact_pv.png +0 -0
- data/public/images/ext/other_pv.png +0 -0
- data/public/images/ext/page_pv.png +0 -0
- data/public/images/ext/page_tiny.png +0 -0
- data/public/images/ext/pdf_pv.png +0 -0
- data/public/images/ext/post_pv.png +0 -0
- data/public/images/ext/post_tiny.png +0 -0
- data/public/images/ext/project_pv.png +0 -0
- data/public/images/ext/project_tiny.png +0 -0
- data/public/images/ext/tag_pv.png +0 -0
- data/public/images/ext/zip_pv.png +0 -0
- data/tasks/ann.rake +0 -80
- data/tasks/bones.rake +0 -20
- data/tasks/gem.rake +0 -201
- data/tasks/git.rake +0 -40
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -51
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -292
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/zentest.rake +0 -36
- data/test/fixtures/comments.yml +0 -126
- data/test/fixtures/contact_contents.yml +0 -132
- data/test/fixtures/data_entries.yml +0 -65
- data/test/fixtures/discussions.yml +0 -48
- data/test/fixtures/document_contents.yml +0 -108
- data/test/fixtures/dyn_attributes.yml +0 -66
- data/test/fixtures/groups.yml +0 -86
- data/test/fixtures/groups_users.yml +0 -81
- data/test/fixtures/iformats.yml +0 -29
- data/test/fixtures/links.yml +0 -313
- data/test/fixtures/nodes.yml +0 -2592
- data/test/fixtures/relations.yml +0 -126
- data/test/fixtures/sites.yml +0 -58
- data/test/fixtures/template_contents.yml +0 -172
- data/test/fixtures/users.yml +0 -167
- data/test/fixtures/versions.yml +0 -1911
- data/test/fixtures/virtual_classes.yml +0 -87
- data/test/fixtures/zips.yml +0 -15
- data/test/functional/sessions_controller_test.rb +0 -73
|
@@ -24,7 +24,7 @@ class CachedPageTest < Zena::Unit::TestCase
|
|
|
24
24
|
assert File.exists?(path), "Cache file created"
|
|
25
25
|
data = File.open(path) {|f| f.read }
|
|
26
26
|
assert_equal "this is the cached content", data
|
|
27
|
-
assert_equal [nodes_id(:status)
|
|
27
|
+
assert_equal [nodes_id(:status), nodes_id(:bird_jpg)], cache.node_ids
|
|
28
28
|
# test expire
|
|
29
29
|
login(:tiger)
|
|
30
30
|
node = secure!(Node) { nodes(:status) }
|
|
@@ -88,7 +88,7 @@ class CachedPageTest < Zena::Unit::TestCase
|
|
|
88
88
|
assert File.exists?(path), "Cache file created"
|
|
89
89
|
data = File.open(path) {|f| f.read }
|
|
90
90
|
assert_equal "this is the cached content", data
|
|
91
|
-
assert_equal [nodes_id(:status)
|
|
91
|
+
assert_equal [nodes_id(:status), nodes_id(:bird_jpg)], cache.node_ids
|
|
92
92
|
# test expire
|
|
93
93
|
CachedPage.expire_old
|
|
94
94
|
assert !File.exists?(path), "Cache file removed"
|
data/test/unit/comment_test.rb
CHANGED
|
@@ -124,7 +124,6 @@ class CommentTest < Zena::Unit::TestCase
|
|
|
124
124
|
comment = comments(:public_says_in_en)
|
|
125
125
|
prop_reply = secure!(Comment) { Comment.create(:discussion_id => comment[:discussion_id], :reply_to=>comment[:id], :title=>'bob', :author_name=>'any', :text=>'blah') }
|
|
126
126
|
|
|
127
|
-
err prop_reply
|
|
128
127
|
assert !prop_reply.new_record?, "Not a new record"
|
|
129
128
|
assert_equal Zena::Status[:prop], prop_reply[:status]
|
|
130
129
|
|
data/test/unit/document_test.rb
CHANGED
|
@@ -7,22 +7,34 @@ class DocumentTest < Zena::Unit::TestCase
|
|
|
7
7
|
without_files('/test.host/data') do
|
|
8
8
|
login(:ant)
|
|
9
9
|
doc = secure!(Document) { Document.create( :parent_id=>nodes_id(:cleanWater),
|
|
10
|
-
:
|
|
11
|
-
:c_file => uploaded_pdf('water.pdf') ) }
|
|
10
|
+
:c_file => uploaded_pdf('water.pdf', 'report.pdf') ) }
|
|
12
11
|
assert_kind_of Document , doc
|
|
13
|
-
assert ! doc.new_record?
|
|
14
|
-
assert_equal
|
|
15
|
-
assert_equal
|
|
16
|
-
assert_equal
|
|
12
|
+
assert ! doc.new_record?
|
|
13
|
+
assert_equal 'report', doc.name
|
|
14
|
+
assert_equal 'projects/cleanWater/report', doc.fullpath
|
|
15
|
+
assert_equal 'report', doc.version.title
|
|
16
|
+
assert_equal 'report.pdf', doc.filename
|
|
17
17
|
assert_equal 'pdf', doc.version.content.ext
|
|
18
|
-
assert ! doc.version.new_record?
|
|
19
|
-
assert_not_nil doc.version.content.id
|
|
20
|
-
assert_kind_of DocumentContent
|
|
18
|
+
assert ! doc.version.new_record?
|
|
19
|
+
assert_not_nil doc.version.content.id
|
|
20
|
+
assert_kind_of DocumentContent, doc.version.content
|
|
21
21
|
assert File.exist?(doc.version.content.filepath)
|
|
22
22
|
assert_equal File.stat(doc.version.content.filepath).size, doc.version.content.size
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
def test_create_same_name
|
|
27
|
+
without_files('/test.host/data') do
|
|
28
|
+
login(:tiger)
|
|
29
|
+
node = secure!(Document) { Document.create( :parent_id => nodes_id(:cleanWater),
|
|
30
|
+
:v_title => 'lake',
|
|
31
|
+
:c_file => uploaded_pdf('water.pdf') ) }
|
|
32
|
+
assert !node.new_record?
|
|
33
|
+
assert_equal 'lake-1', node.name
|
|
34
|
+
assert_equal 'lake-1', node.version.title
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
26
38
|
def test_create_with_bad_filename
|
|
27
39
|
preserving_files('/test.host/data') do
|
|
28
40
|
login(:ant)
|
|
@@ -176,7 +188,7 @@ class DocumentTest < Zena::Unit::TestCase
|
|
|
176
188
|
without_files('/test.host/data') do
|
|
177
189
|
login(:ant)
|
|
178
190
|
doc = secure!(Document) { Document.create( :parent_id=>nodes_id(:cleanWater),
|
|
179
|
-
:c_file =>
|
|
191
|
+
:c_file => uploaded_fixture("some.txt", 'application/octet-stream', "super.zz") ) }
|
|
180
192
|
assert_kind_of Document , doc
|
|
181
193
|
assert ! doc.new_record? , "Not a new record"
|
|
182
194
|
assert_equal "super", doc.name
|
|
@@ -219,7 +231,7 @@ class DocumentTest < Zena::Unit::TestCase
|
|
|
219
231
|
without_files('/test.host/data') do
|
|
220
232
|
login(:ant)
|
|
221
233
|
doc = secure!(Document) { Document.create( :parent_id=>nodes_id(:cleanWater),
|
|
222
|
-
:c_file =>
|
|
234
|
+
:c_file => uploaded_fixture('water.pdf', 'application/pdf', 'wat'), :v_title => "lazy waters.pdf") }
|
|
223
235
|
assert_kind_of Document , doc
|
|
224
236
|
assert ! doc.new_record? , "Not a new record"
|
|
225
237
|
assert_equal "lazyWaters", doc.name
|
|
@@ -41,16 +41,20 @@ class MultiVersionTest < Zena::Unit::TestCase
|
|
|
41
41
|
context 'when there is only a redaction for the current language' do
|
|
42
42
|
setup do
|
|
43
43
|
login(:tiger)
|
|
44
|
-
version = secure!(Version) { versions(:
|
|
45
|
-
node = version.node
|
|
46
|
-
|
|
47
|
-
assert_equal [:opening_red_fr, :opening_en].map{|s| versions_id(s)}.sort, node.versions.map{|v| v.id}.sort
|
|
48
|
-
login(:anon)
|
|
44
|
+
version = secure!(Version) { versions(:opening_en) }
|
|
45
|
+
@node = version.node
|
|
46
|
+
@node.destroy_version
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
should 'see a default publication' do
|
|
50
|
+
login(:anon)
|
|
52
51
|
node = secure!(Node) { nodes(:opening) }
|
|
53
|
-
assert_equal versions_id(:
|
|
52
|
+
assert_equal versions_id(:opening_fr), node.version.id
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
should 'see other redaction an publication in another language ' do
|
|
56
|
+
login(:tiger)
|
|
57
|
+
assert_equal [:opening_red_fr, :opening_fr].map{|s| versions_id(s)}.sort, @node.versions.map{|v| v.id}.sort
|
|
54
58
|
end
|
|
55
59
|
end
|
|
56
60
|
end # A visitor without write access
|
|
@@ -81,18 +85,22 @@ class MultiVersionTest < Zena::Unit::TestCase
|
|
|
81
85
|
context 'in a language not supported' do
|
|
82
86
|
setup do
|
|
83
87
|
login(:tiger)
|
|
84
|
-
version = secure!(Version) { versions(:
|
|
85
|
-
node = version.node
|
|
86
|
-
|
|
87
|
-
assert_equal [:opening_red_fr, :opening_en].map{|s| versions_id(s)}.sort, node.versions.map{|v| v.id}.sort
|
|
88
|
-
login(:ant)
|
|
88
|
+
version = secure!(Version) { versions(:opening_en) }
|
|
89
|
+
@node = version.node
|
|
90
|
+
@node.destroy_version
|
|
89
91
|
end
|
|
90
92
|
|
|
91
93
|
should 'see redaction from another language' do
|
|
94
|
+
login(:ant)
|
|
92
95
|
visitor.lang = 'de'
|
|
93
96
|
node = secure!(Node) { nodes(:opening) }
|
|
94
97
|
assert_equal versions_id(:opening_red_fr), node.version.id
|
|
95
98
|
end
|
|
99
|
+
|
|
100
|
+
should 'see redaction and publication from another language' do
|
|
101
|
+
login(:tiger)
|
|
102
|
+
assert_equal [:opening_red_fr, :opening_fr].map{|s| versions_id(s)}.sort, @node.versions.map{|v| v.id}.sort
|
|
103
|
+
end
|
|
96
104
|
end
|
|
97
105
|
|
|
98
106
|
should 'see a redaction if there are no publications' do
|
|
@@ -118,7 +126,7 @@ class MultiVersionTest < Zena::Unit::TestCase
|
|
|
118
126
|
login(:ant)
|
|
119
127
|
visitor.status = User::Status[:moderated]
|
|
120
128
|
end
|
|
121
|
-
|
|
129
|
+
|
|
122
130
|
context 'on an unpublished node' do
|
|
123
131
|
setup do
|
|
124
132
|
@node = secure!(Node) { nodes(:nature) }
|
|
@@ -128,7 +136,7 @@ class MultiVersionTest < Zena::Unit::TestCase
|
|
|
128
136
|
assert_equal versions_id(:nature_red_en), @node.version.id
|
|
129
137
|
end
|
|
130
138
|
end
|
|
131
|
-
|
|
139
|
+
|
|
132
140
|
context 'on a published node with a redaction' do
|
|
133
141
|
setup do
|
|
134
142
|
visitor.lang = 'fr'
|
|
@@ -139,8 +147,8 @@ class MultiVersionTest < Zena::Unit::TestCase
|
|
|
139
147
|
assert_equal versions_id(:opening_red_fr), @node.version.id
|
|
140
148
|
end
|
|
141
149
|
end
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
|
|
151
|
+
|
|
144
152
|
end
|
|
145
153
|
# =========== UPDATE VERSION TESTS =============
|
|
146
154
|
|
|
@@ -514,7 +522,7 @@ class MultiVersionTest < Zena::Unit::TestCase
|
|
|
514
522
|
assert @node.update_attributes(:v_title => 'Larry Summers is a jerk.')
|
|
515
523
|
end
|
|
516
524
|
end
|
|
517
|
-
|
|
525
|
+
|
|
518
526
|
should 'replace old publication autopublishing' do
|
|
519
527
|
@node.update_attributes(:v_title => 'Is not very apt at the high end.')
|
|
520
528
|
assert_equal Zena::Status[:rep], versions(:collections_en).status
|
data/test/unit/node_test.rb
CHANGED
|
@@ -10,15 +10,28 @@ class NodeTest < Zena::Unit::TestCase
|
|
|
10
10
|
:parent_id => Zena::FoxyParser::id('zena', 'cleanWater'),
|
|
11
11
|
}.freeze
|
|
12
12
|
|
|
13
|
-
def
|
|
13
|
+
def test_rebuild_fullpath
|
|
14
14
|
Node.connection.execute "UPDATE nodes SET fullpath = NULL, basepath = NULL WHERE id = #{nodes_id(:wiki)}"
|
|
15
15
|
login(:ant)
|
|
16
16
|
node = nodes(:wiki)
|
|
17
17
|
assert_nil node[:fullpath]
|
|
18
|
-
node
|
|
18
|
+
node.send(:rebuild_fullpath)
|
|
19
19
|
assert_equal 'projects/wiki', node.fullpath
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_rebuild_fullpath_in_custom_base
|
|
23
|
+
Node.connection.execute "UPDATE nodes SET fullpath = NULL, basepath = NULL WHERE id = #{nodes_id(:status)}"
|
|
24
|
+
login(:ant)
|
|
25
|
+
node = nodes(:status)
|
|
26
|
+
assert_nil node[:fullpath]
|
|
27
|
+
node.send(:rebuild_fullpath)
|
|
28
|
+
assert_equal 'projects/cleanWater/status', node.fullpath
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_find_by_path
|
|
32
|
+
login(:ant)
|
|
20
33
|
node = secure!(Node) { Node.find_by_path('projects/wiki') }
|
|
21
|
-
assert_equal
|
|
34
|
+
assert_equal nodes_id(:wiki), node.id
|
|
22
35
|
end
|
|
23
36
|
|
|
24
37
|
def test_match_query
|
|
@@ -73,38 +86,12 @@ class NodeTest < Zena::Unit::TestCase
|
|
|
73
86
|
end
|
|
74
87
|
end
|
|
75
88
|
|
|
76
|
-
def test_get_fullpath
|
|
77
|
-
Node.connection.execute "UPDATE nodes SET fullpath = NULL, basepath = NULL WHERE id IN (#{nodes_id(:lake)},#{nodes_id(:cleanWater)})"
|
|
78
|
-
login(:ant)
|
|
79
|
-
node = secure!(Node) { nodes(:lake) }
|
|
80
|
-
parent = node.parent
|
|
81
|
-
assert_nil parent[:fullpath]
|
|
82
|
-
assert_nil node[:fullpath]
|
|
83
|
-
assert_equal 'projects/cleanWater/lakeAddress', node.fullpath
|
|
84
|
-
node.reload
|
|
85
|
-
assert_equal 'projects/cleanWater/lakeAddress', node[:fullpath]
|
|
86
|
-
parent.reload
|
|
87
|
-
assert_equal 'projects/cleanWater', parent[:fullpath]
|
|
88
|
-
end
|
|
89
|
-
|
|
90
89
|
def test_get_fullpath_rebuild
|
|
91
|
-
login(:
|
|
90
|
+
login(:lion)
|
|
92
91
|
node = secure!(Node) { nodes(:lake) }
|
|
93
92
|
assert_equal 'projects/cleanWater/lakeAddress', node.fullpath
|
|
94
|
-
|
|
95
|
-
node.
|
|
96
|
-
assert_equal 'projects/cleanWater/lakeAddress', node.fullpath
|
|
97
|
-
assert_equal 'collections/lakeAddress', node.fullpath(true)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def test_get_fullpath_after_private
|
|
101
|
-
Node.connection.execute "UPDATE nodes SET parent_id = #{nodes_id(:ant)} WHERE id = #{nodes_id(:status)}" # put 'status' page inside private 'ant' page
|
|
102
|
-
node = nil
|
|
103
|
-
login(:tiger)
|
|
104
|
-
assert_nothing_raised { node = secure!(Node) { nodes(:status) } }
|
|
105
|
-
assert_kind_of Node, node
|
|
106
|
-
assert_nothing_raised { node = secure!(Node) { Node.find_by_path('people/ant') } }
|
|
107
|
-
assert_nothing_raised { node = secure!(Node) { Node.find_by_path('people/ant/status')}}
|
|
93
|
+
assert node.update_attributes(:parent_id => nodes_id(:collections))
|
|
94
|
+
assert_equal 'collections/lakeAddress', node.fullpath
|
|
108
95
|
end
|
|
109
96
|
|
|
110
97
|
def test_fullpath_updated_on_parent_rename
|
|
@@ -119,8 +106,7 @@ class NodeTest < Zena::Unit::TestCase
|
|
|
119
106
|
assert node.publish
|
|
120
107
|
assert_equal 'nicePeople', node.name # sync name
|
|
121
108
|
node = secure!(Node) { nodes(:tiger) }
|
|
122
|
-
|
|
123
|
-
assert_equal 'nicePeople/tiger', node.fullpath
|
|
109
|
+
assert_equal 'nicePeople/tiger', node[:fullpath]
|
|
124
110
|
end
|
|
125
111
|
|
|
126
112
|
def test_rootpath
|
|
@@ -174,6 +160,10 @@ class NodeTest < Zena::Unit::TestCase
|
|
|
174
160
|
test_page = secure!(Node) { Node.create(:name=>"yoba", :parent_id => nodes_id(:cleanWater), :inherit=>1 ) }
|
|
175
161
|
assert ! test_page.new_record? , "Not a new record"
|
|
176
162
|
assert_equal nodes_id(:cleanWater), test_page.parent[:id]
|
|
163
|
+
assert_equal 'projects/cleanWater/yoba', test_page.fullpath
|
|
164
|
+
assert_equal 'projects/cleanWater', test_page.basepath
|
|
165
|
+
parent = secure!(Node) { nodes(:cleanWater) }
|
|
166
|
+
assert_equal 'projects/cleanWater', parent.fullpath
|
|
177
167
|
end
|
|
178
168
|
|
|
179
169
|
def test_cannot_update_v_status
|
|
@@ -637,7 +627,7 @@ class NodeTest < Zena::Unit::TestCase
|
|
|
637
627
|
login(:lion)
|
|
638
628
|
node = secure!(Node) { nodes(:art) }
|
|
639
629
|
assert node.update_attributes('tagged_ids' => [nodes_id(:status), nodes_id(:people)])
|
|
640
|
-
assert_equal 2, node.find(:all, 'tagged').size
|
|
630
|
+
assert_equal 2, node.find(:all, 'tagged', :skip_rubyless => true).size
|
|
641
631
|
stat = secure!(Node) { nodes(:status) }
|
|
642
632
|
peop = secure!(Node) { nodes(:people) }
|
|
643
633
|
assert_equal node[:id], stat.find(:first, 'set_tags')[:id]
|
|
@@ -994,9 +984,9 @@ done: \"I am done\""
|
|
|
994
984
|
end
|
|
995
985
|
|
|
996
986
|
def test_to_yaml
|
|
997
|
-
test_site('zena')
|
|
998
|
-
User.connection.execute "UPDATE users SET time_zone = 'Asia/Jakarta' WHERE id = #{users_id(:tiger)}"
|
|
987
|
+
#test_site('zena')
|
|
999
988
|
login(:tiger)
|
|
989
|
+
visitor.time_zone = 'Asia/Jakarta'
|
|
1000
990
|
assert_equal 'Asia/Jakarta', visitor.time_zone
|
|
1001
991
|
status = secure!(Node) { nodes(:status) }
|
|
1002
992
|
assert status.update_attributes_with_transformation(:v_status => Zena::Status[:pub], :v_text => "This is a \"link\":#{nodes_zip(:projects)}.", :d_foo => "A picture: !#{nodes_zip(:bird_jpg)}!")
|
|
@@ -1004,7 +994,11 @@ done: \"I am done\""
|
|
|
1004
994
|
assert_match %r{v_text:\s+\"?This is a "link":\(\.\./\.\.\)\.}, yaml
|
|
1005
995
|
assert_match %r{d_foo:\s+\"?A picture: !\(\.\./\.\./wiki/bird\)!}, yaml
|
|
1006
996
|
assert_no_match %r{log_at}, yaml
|
|
997
|
+
end
|
|
1007
998
|
|
|
999
|
+
def test_to_yaml_with_change_log_at
|
|
1000
|
+
login(:tiger)
|
|
1001
|
+
visitor.time_zone = 'Asia/Jakarta'
|
|
1008
1002
|
prop = secure!(Node) { nodes(:proposition) }
|
|
1009
1003
|
assert prop.update_attributes_with_transformation(:v_status => Zena::Status[:pub], :v_text => "This is a \"link\":#{nodes_zip(:projects)}.", :d_foo => "A picture: !#{nodes_zip(:bird_jpg)}!", :log_at => "2008-10-20 14:53")
|
|
1010
1004
|
assert_equal Time.gm(2008,10,20,7,53), prop.log_at
|
|
@@ -1090,61 +1084,6 @@ done: \"I am done\""
|
|
|
1090
1084
|
assert_equal nodes_id(:opening), match[0][:id]
|
|
1091
1085
|
end
|
|
1092
1086
|
|
|
1093
|
-
def find_nodes_with_pagination_in_cleanWaterProject(page, per_page = 3, opts=nil)
|
|
1094
|
-
previous_page, collection, next_page = nil, nil, nil
|
|
1095
|
-
opts ||= {:conditions => ['project_id = ?', nodes_id(:cleanWater)], :order=>'name ASC'}
|
|
1096
|
-
collection = secure(Node) do
|
|
1097
|
-
previous_page, collection, next_page = Node.find_with_pagination(:all, opts.merge(:page=>page, :per_page=>per_page))
|
|
1098
|
-
collection
|
|
1099
|
-
end
|
|
1100
|
-
[previous_page, collection, next_page]
|
|
1101
|
-
end
|
|
1102
|
-
|
|
1103
|
-
def test_find_with_pagination_page_1
|
|
1104
|
-
login(:tiger)
|
|
1105
|
-
previous_page, collection, next_page = find_nodes_with_pagination_in_cleanWaterProject(1,3)
|
|
1106
|
-
assert_nil previous_page
|
|
1107
|
-
assert_equal 2, next_page
|
|
1108
|
-
assert_equal 3, collection.size
|
|
1109
|
-
assert_equal [:bananas, :crocodiles, :lake_jpg].map{|s| nodes_id(s)}, collection.map{|r| r[:id]}
|
|
1110
|
-
end
|
|
1111
|
-
|
|
1112
|
-
def test_find_with_pagination_page_2
|
|
1113
|
-
login(:tiger)
|
|
1114
|
-
previous_page, collection, next_page = find_nodes_with_pagination_in_cleanWaterProject(2,3)
|
|
1115
|
-
assert_equal 1, previous_page
|
|
1116
|
-
assert_equal 3, next_page
|
|
1117
|
-
assert_equal 3, collection.size
|
|
1118
|
-
assert_equal [:lake, :opening, :status].map{|s| nodes_id(s)}, collection.map{|r| r[:id]}
|
|
1119
|
-
end
|
|
1120
|
-
|
|
1121
|
-
def test_find_with_pagination_page_3
|
|
1122
|
-
login(:tiger)
|
|
1123
|
-
previous_page, collection, next_page = find_nodes_with_pagination_in_cleanWaterProject(3,3)
|
|
1124
|
-
assert_equal 2, previous_page
|
|
1125
|
-
assert_nil next_page
|
|
1126
|
-
assert_equal 2, collection.size
|
|
1127
|
-
assert_equal [:track, :water_pdf].map{|s| nodes_id(s)}, collection.map{|r| r[:id]}
|
|
1128
|
-
end
|
|
1129
|
-
|
|
1130
|
-
def test_find_with_pagination_page_4
|
|
1131
|
-
login(:tiger)
|
|
1132
|
-
previous_page, collection, next_page = find_nodes_with_pagination_in_cleanWaterProject(4,3)
|
|
1133
|
-
assert_equal 3, previous_page
|
|
1134
|
-
assert_nil next_page
|
|
1135
|
-
assert_nil collection
|
|
1136
|
-
end
|
|
1137
|
-
|
|
1138
|
-
def test_find_match_with_pagination
|
|
1139
|
-
login(:tiger)
|
|
1140
|
-
previous_page, match, next_page, count_all = secure!(Node) { Node.find_with_pagination(:all, Node.match_query('opening').merge(:page => 1, :per_page => 3)) }
|
|
1141
|
-
assert_equal 1, match.size
|
|
1142
|
-
assert_equal 1, count_all
|
|
1143
|
-
assert_nil previous_page
|
|
1144
|
-
assert_nil next_page
|
|
1145
|
-
assert_equal nodes_id(:opening), match[0][:id]
|
|
1146
|
-
end
|
|
1147
|
-
|
|
1148
1087
|
def test_data
|
|
1149
1088
|
login(:ant)
|
|
1150
1089
|
node = secure!(Node) { nodes(:cleanWater) }
|
|
@@ -1245,7 +1184,7 @@ done: \"I am done\""
|
|
|
1245
1184
|
|
|
1246
1185
|
# position has different scopes depending on first two letters of kpath: 'ND', 'NN', 'NP', 'NR'
|
|
1247
1186
|
doc = secure!(Document) { Document.create( :parent_id=>nodes_id(:cleanWater),
|
|
1248
|
-
:c_file =>
|
|
1187
|
+
:c_file => uploaded_fixture('water.pdf', 'application/pdf', 'wat'), :v_title => "lazy waters.pdf") }
|
|
1249
1188
|
assert !doc.new_record?
|
|
1250
1189
|
assert_equal 0.0, doc.position
|
|
1251
1190
|
|
data/test/unit/note_test.rb
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
require 'test_helper'
|
|
2
2
|
|
|
3
3
|
class NoteTest < Zena::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def test_create_simplest
|
|
6
|
+
login(:ant)
|
|
7
|
+
test_page = secure!(Note) { Note.create(:name=>"yoba", :parent_id => nodes_id(:cleanWater), :inherit=>1 ) }
|
|
8
|
+
assert ! test_page.new_record? , "Not a new record"
|
|
9
|
+
assert_equal nodes_id(:cleanWater), test_page.parent[:id]
|
|
10
|
+
assert_equal 'projects/cleanWater/yoba', test_page.fullpath
|
|
11
|
+
assert_equal 'projects/cleanWater', test_page.basepath
|
|
12
|
+
end
|
|
4
13
|
|
|
5
14
|
def test_create_with_name
|
|
6
15
|
login(:tiger)
|
data/test/unit/page_test.rb
CHANGED
|
@@ -73,7 +73,7 @@ class PageTest < Zena::Unit::TestCase
|
|
|
73
73
|
assert_equal node[:id], bird[:parent_id]
|
|
74
74
|
assert node.update_attributes(:custom_base => true)
|
|
75
75
|
assert_equal 'projects/aWikiWithZena', node.basepath
|
|
76
|
-
bird = secure!(Node) { nodes(:bird_jpg)}
|
|
77
|
-
assert_equal 'projects/aWikiWithZena', bird.basepath
|
|
76
|
+
bird = secure!(Node) { nodes(:bird_jpg)}
|
|
77
|
+
assert_equal 'projects/aWikiWithZena', bird.basepath
|
|
78
78
|
end
|
|
79
79
|
end
|
data/test/unit/secure_test.rb
CHANGED
|
@@ -74,7 +74,7 @@ class SecureTest < Zena::Unit::TestCase
|
|
|
74
74
|
context 'loaded without secure' do
|
|
75
75
|
setup do
|
|
76
76
|
@node = nodes(:secret)
|
|
77
|
-
|
|
77
|
+
#@visitor.visit(@node)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
should 'receive false when asking can_read?' do
|
|
@@ -256,7 +256,7 @@ class SecureTest < Zena::Unit::TestCase
|
|
|
256
256
|
context 'without secure' do
|
|
257
257
|
should 'not be allowed to build new children' do
|
|
258
258
|
node = Node.new(defaults)
|
|
259
|
-
|
|
259
|
+
assert_raise ActiveRecord::RecordInvalid do node.save! end
|
|
260
260
|
assert_equal 'record not secured', node.errors[:base]
|
|
261
261
|
end
|
|
262
262
|
|
|
@@ -926,14 +926,4 @@ class SecureTest < Zena::Unit::TestCase
|
|
|
926
926
|
end
|
|
927
927
|
end # A visitor with reader status
|
|
928
928
|
|
|
929
|
-
context 'A visitor with deleted status' do
|
|
930
|
-
setup do
|
|
931
|
-
User.connection.execute "UPDATE users SET status = #{User::Status[:deleted]} WHERE id = #{users_id(:tiger)} AND site_id = #{sites_id(:zena)}"
|
|
932
|
-
end
|
|
933
|
-
|
|
934
|
-
should 'not be able to login' do
|
|
935
|
-
login(:tiger)
|
|
936
|
-
assert_equal users(:anon), visitor
|
|
937
|
-
end
|
|
938
|
-
end # A visitor with deleted status
|
|
939
929
|
end
|
data/test/unit/site_test.rb
CHANGED
|
@@ -2,34 +2,28 @@ require 'test_helper'
|
|
|
2
2
|
|
|
3
3
|
class SiteTest < Zena::Unit::TestCase
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
assert_equal "Anonymous User", site.anon.fullname
|
|
10
|
-
assert_not_equal users(:anon), site.anon[:id]
|
|
11
|
-
assert admin = User.login('admin', 'secret', 'super.host'), "Admin user can login"
|
|
12
|
-
|
|
13
|
-
assert_equal 3, admin.group_ids.size
|
|
14
|
-
root = secure!(Node) { Node.find(site[:root_id]) }
|
|
15
|
-
assert_kind_of Project, root
|
|
16
|
-
assert_equal Zena::Status[:pub], root.version.status
|
|
17
|
-
assert_equal 'default', root.skin
|
|
5
|
+
context 'on site creation' do
|
|
6
|
+
setup do
|
|
7
|
+
@site = Site.create_for_host('super.host', 'secret')
|
|
8
|
+
end
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
should 'populate super user' do
|
|
11
|
+
assert_equal "Super User", @site.su.fullname
|
|
12
|
+
assert_not_equal users(:su), @site.su[:id]
|
|
13
|
+
end
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
should 'populate anonymous user' do
|
|
16
|
+
assert_equal "Anonymous User", @site.anon.fullname
|
|
17
|
+
assert_not_equal users(:anon), @site.anon[:id]
|
|
18
|
+
end
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
assert_kind_of Contact, anon.contact
|
|
20
|
+
should 'populate 2 admin users' do
|
|
21
|
+
assert_equal 2, @site.admin_user_ids.size
|
|
22
|
+
end
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
should 'return a new project as root node' do
|
|
25
|
+
assert_kind_of Project, @site.root_node
|
|
26
|
+
end
|
|
33
27
|
end
|
|
34
28
|
|
|
35
29
|
def test_create_site_with_opts
|
|
@@ -233,4 +227,29 @@ class SiteTest < Zena::Unit::TestCase
|
|
|
233
227
|
assert_equal Hash['w'=>{'fr' => versions_id(:opening_red_fr), 'en' => versions_id(:opening_en)},
|
|
234
228
|
'r'=>{'fr' => versions_id(:opening_fr), 'en' => versions_id(:opening_en)}], opening.vhash
|
|
235
229
|
end
|
|
230
|
+
|
|
231
|
+
def test_rebuild_fullpath
|
|
232
|
+
login(:tiger)
|
|
233
|
+
Node.connection.execute "UPDATE nodes SET fullpath = NULL"
|
|
234
|
+
visitor.site.rebuild_fullpath
|
|
235
|
+
status = secure(Node) { nodes(:status) }
|
|
236
|
+
opening = secure(Node) { nodes(:opening) }
|
|
237
|
+
cleanWater = secure(Node) { nodes(:cleanWater) }
|
|
238
|
+
art = secure(Node) { nodes(:art) }
|
|
239
|
+
assert_equal 'projects/cleanWater/status', status.fullpath
|
|
240
|
+
assert_equal 'projects/cleanWater', status.basepath
|
|
241
|
+
assert_equal false, status.custom_base
|
|
242
|
+
|
|
243
|
+
assert_equal 'projects/cleanWater/opening', opening.fullpath
|
|
244
|
+
assert_equal 'projects/cleanWater', opening.basepath
|
|
245
|
+
assert_equal false, opening.custom_base
|
|
246
|
+
|
|
247
|
+
assert_equal 'projects/cleanWater', cleanWater.fullpath
|
|
248
|
+
assert_equal 'projects/cleanWater', cleanWater.basepath
|
|
249
|
+
assert_equal true, cleanWater.custom_base
|
|
250
|
+
|
|
251
|
+
assert_equal 'collections/art', art.fullpath
|
|
252
|
+
assert_equal '', art.basepath
|
|
253
|
+
assert_equal false, art.custom_base
|
|
254
|
+
end
|
|
236
255
|
end
|