Tweak setting initialization
I could not see a meaningful reason behind calling `forbid` so early in the settings initialization block. But moving the `forbid` call until later resolved this issue. In the real world, I don't see how this would cause issues. But I found that calling `forbid` when `wiki_options[:allow_editing]` was set to false caused order-dependent test errors where Sprockets would end up being badly configured and left without an initialized `Sprockets::Environment` object, which is required by the `sprockets-helpers` gem to resolve asset paths. The test that would cause errors is also in this commit diff. I've updated it to be a bit more readable. I also took this opportunity to review and clean up the `@allow_editing` assignment, which seemed a bit obfuscated.
This commit is contained in:
@@ -3,8 +3,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
context "Precious::Views::Editing" do
|
||||
include Rack::Test::Methods
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath('examples/revert.git')
|
||||
@path = cloned_testpath('examples/revert.git')
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
end
|
||||
@@ -13,14 +14,20 @@ context "Precious::Views::Editing" do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
test "creating page is blocked" do
|
||||
Precious::App.set(:wiki_options, { allow_editing: false})
|
||||
post "/gollum/create", :content => 'abc', :page => "D",
|
||||
:format => 'markdown', :message => 'def'
|
||||
assert !last_response.ok?
|
||||
test 'creating pages is blocked' do
|
||||
Precious::App.set(:wiki_options, {allow_editing: false})
|
||||
|
||||
page = @wiki.page('D')
|
||||
assert page.nil?
|
||||
post '/gollum/create',
|
||||
content: 'abc',
|
||||
format: 'markdown',
|
||||
message: 'def',
|
||||
page: 'D'
|
||||
|
||||
assert last_response.body.include? 'Forbidden. This wiki is set to no-edit mode.'
|
||||
|
||||
refute last_response.ok?
|
||||
|
||||
assert_nil @wiki.page('D')
|
||||
end
|
||||
|
||||
test ".redirects.gollum file should not be accessible" do
|
||||
@@ -28,7 +35,7 @@ context "Precious::Views::Editing" do
|
||||
get '/.redirects.gollum'
|
||||
assert_match /Accessing this resource is not allowed/, last_response.body
|
||||
end
|
||||
|
||||
|
||||
test ".redirects.gollum file should not be editable" do
|
||||
Precious::App.set(:wiki_options, { allow_editing: true, allow_uploads: true })
|
||||
get '/gollum/edit/.redirects.gollum'
|
||||
|
||||
Reference in New Issue
Block a user