Skip to content

Commit

Permalink
Interweb includes from published webs
Browse files Browse the repository at this point in the history
  • Loading branch information
distler committed Jun 13, 2020
1 parent 990e631 commit f6f5482
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chunks/include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(match_data, content)
rendering_mode = content.options[:mode] || :show
add_to_include_list
@ref_web = Web.find_by_name(web_name) || Web.find_by_address(web_name)
if @ref_web.password.nil? or @ref_web == @content.web
if @ref_web.password.nil? or @ref_web.published? or @ref_web == @content.web
@unmask_text = get_unmask_text_avoiding_recursion_loops(rendering_mode)
else
@unmask_text = "Access to #{web_name}:#{@page_name} forbidden."
Expand Down
20 changes: 20 additions & 0 deletions test/functional/wiki_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,26 @@ def test_nonrecursive_include_password
set_web_property :password, nil
end

def test_nonrecursive_include_published
set_web_property :password, 'pswd'
set_web_property :published, true
@wiki.write_page('wiki1', 'Bar', "extra fun\n\n[[HomePage]]", Time.now,
Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer)
@wiki.write_page('wiki1', 'Foo', "[[!include Bar]]\n\n[[!include Bar]]", Time.now,
Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer)
@wiki.write_page('wiki1', 'HomePage', "Nonrecursive-include:\n\n[[!include Foo]]", Time.now,
Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer)

# Again, this shouldn't be here. Detritus from another test?
File.delete(File.join(RAILS_ROOT, 'tmp', 'cache', "wiki1_HomePage.cache"))
r = process('published', 'id' => 'HomePage', 'web' => 'wiki1')

assert_response :success
assert_match(/<p>Nonrecursive-include:<\/p>\n\n<p>extra fun<\/p>\n\n<p><a class='existingWikiWord' href='\/wiki1\/published\/HomePage'>HomePage<\/a><\/p>/, r.body)
set_web_property :password, nil
set_web_property :published, nil
end

def test_divref
@wiki.write_page('wiki1', 'Bar', "+-- \{: .num_lemma #Leftcosetsdisjoint\}\n###### Lem" +
"ma\nLet $H$ be a subgroup of a group $G$, and let $x$ and $y$ be elements\n of $G$" +
Expand Down

0 comments on commit f6f5482

Please sign in to comment.