Commit 0c8b097a06462285c117d90065dce2941678b86c

Authored by Junior Silva
Committed by Rodrigo Souto
1 parent fc17dcd3

topic-forum: implemented final test to author topic permissions

AI3135
test/functional/content_viewer_controller_test.rb
@@ -896,12 +896,34 @@ class ContentViewerControllerTest < ActionController::TestCase @@ -896,12 +896,34 @@ class ContentViewerControllerTest < ActionController::TestCase
896 896
897 should 'display icon-edit button to author topic' do 897 should 'display icon-edit button to author topic' do
898 community = fast_create(Community) 898 community = fast_create(Community)
899 - author = fast_create(Person) 899 + admin = fast_create(Person)
  900 + community.add_member(admin)
  901 + author = create_user('author').person
900 community.add_member(author) 902 community.add_member(author)
  903 +
901 forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test') 904 forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test')
902 post = fast_create(TextileArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :last_changed_by_id => author.id) 905 post = fast_create(TextileArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :last_changed_by_id => author.id)
903 906
904 - assert_select 'div#article-actions' 907 + login_as(author.identifier)
  908 + get :view_page, :profile => community.identifier, :page => post.path.split('/')
  909 +
  910 + assert_select "div#article-actions a.icon-edit"
  911 + end
  912 +
  913 + should 'display icon-delete button to author topic' do
  914 + community = fast_create(Community)
  915 + admin = fast_create(Person)
  916 + community.add_member(admin)
  917 + author = create_user('author').person
  918 + community.add_member(author)
  919 +
  920 + forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test')
  921 + post = fast_create(TextileArticle, :name => 'First post', :profile_id => community.id, :parent_id => forum.id, :last_changed_by_id => author.id)
  922 +
  923 + login_as(author.identifier)
  924 + get :view_page, :profile => community.identifier, :page => post.path.split('/')
  925 +
  926 + assert_select "div#article-actions a.icon-delete"
905 end 927 end
906 928
907 should 'add meta tag to rss feed on view forum' do 929 should 'add meta tag to rss feed on view forum' do
test/unit/article_test.rb
@@ -1663,6 +1663,8 @@ class ArticleTest < ActiveSupport::TestCase @@ -1663,6 +1663,8 @@ class ArticleTest < ActiveSupport::TestCase
1663 1663
1664 should 'allow author to edit topic' do 1664 should 'allow author to edit topic' do
1665 community = fast_create(Community) 1665 community = fast_create(Community)
  1666 + admin = fast_create(Person)
  1667 + community.add_member(admin)
1666 author = fast_create(Person) 1668 author = fast_create(Person)
1667 community.add_member(author) 1669 community.add_member(author)
1668 forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test') 1670 forum = Forum.create(:profile => community, :name => 'Forum test', :body => 'Forum test')