41 lines
1.3 KiB
Ruby
41 lines
1.3 KiB
Ruby
require File.expand_path('../../test_helper', __FILE__)
|
|
|
|
class WikiPageDropTest < ActiveSupport::TestCase
|
|
def setup
|
|
@project = Project.generate!
|
|
@wiki = Wiki.generate(:project => @project)
|
|
@wiki_page = WikiPage.generate!(:wiki => @wiki)
|
|
User.current = @user = User.generate!
|
|
@role = Role.generate!(:permissions => [:view_wiki_pages])
|
|
Member.generate!(:principal => @user, :project => @project, :roles => [@role])
|
|
@drop = @wiki_page.to_liquid
|
|
end
|
|
|
|
context "drop" do
|
|
should "be a WikiPageDrop" do
|
|
assert @drop.is_a?(WikiPageDrop), "drop is not a WikiPageDrop"
|
|
end
|
|
end
|
|
|
|
|
|
context "#title" do
|
|
should "return the title of the wiki page" do
|
|
assert_equal @wiki_page.title, @drop.title
|
|
end
|
|
end
|
|
|
|
should "only load an object if it's visible to the current user" do
|
|
assert User.current.logged?
|
|
assert @wiki_page.visible?
|
|
|
|
@private_project = Project.generate!(:is_public => false)
|
|
@private_wiki = Wiki.generate!(:project => @private_project)
|
|
@private_wiki_page = WikiPage.generate!(:wiki => @private_wiki)
|
|
|
|
assert !@private_wiki_page.visible?, "WikiPage is visible"
|
|
@private_drop = WikiPageDrop.new(@private_wiki_page)
|
|
assert_equal nil, @private_drop.instance_variable_get("@object")
|
|
assert_equal nil, @private_drop.title
|
|
end
|
|
end
|