diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index a42e67c..cc19542 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -3,7 +3,8 @@ require_relative "../test_helper" class CommunityTest < ActiveSupport::TestCase def setup - @person = fast_create(Person) + @user = User.current = create_user + @person = @user.person end attr_reader :person @@ -287,8 +288,8 @@ class CommunityTest < ActiveSupport::TestCase should "update the action of article creation when an community's article is commented" do ActionTrackerNotification.delete_all - p1 = Person.first community = fast_create(Community) + p1 = person p2 = create_user.person p3 = create_user.person community.add_member(p3) diff --git a/test/unit/textile_article_test.rb b/test/unit/textile_article_test.rb index cb3ac15..21d0a18 100644 --- a/test/unit/textile_article_test.rb +++ b/test/unit/textile_article_test.rb @@ -3,7 +3,8 @@ require_relative "../test_helper" class TextileArticleTest < ActiveSupport::TestCase def setup - @profile = create_user('testing').person + @user = User.current = create_user 'testing' + @profile = @user.person end attr_reader :profile @@ -16,7 +17,7 @@ class TextileArticleTest < ActiveSupport::TestCase end should 'convert Textile to HTML' do - assert_equal '
my text
', build(TextileArticle, :body => '*my text*').to_html + assert_equal 'my text
', build(TextileArticle, body: '*my text*').to_html end should 'accept empty body' do @@ -34,23 +35,21 @@ class TextileArticleTest < ActiveSupport::TestCase should 'notify activity on create' do ActionTracker::Record.delete_all - create TextileArticle, :name => 'test', :profile_id => fast_create(Profile).id, :published => true + create TextileArticle, name: 'test', profile_id: profile.id, published: true assert_equal 1, ActionTracker::Record.count end should 'not group trackers activity of article\'s creation' do - profile = fast_create(Profile) assert_difference 'ActionTracker::Record.count', 3 do - create TextileArticle, :name => 'bar', :profile_id => profile.id, :published => true - create TextileArticle, :name => 'another bar', :profile_id => profile.id, :published => true - create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true + create TextileArticle, name: 'bar', profile_id: profile.id, published: true + create TextileArticle, name: 'another bar', profile_id: profile.id, published: true + create TextileArticle, name: 'another bar 2', profile_id: profile.id, published: true end end should 'not update activity on update of an article' do ActionTracker::Record.delete_all - profile = fast_create(Profile) - article = create(TextileArticle, :profile_id => profile.id) + article = create(TextileArticle, profile_id: profile.id) time = article.activity.updated_at Time.stubs(:now).returns(time + 1.day) assert_no_difference 'ActionTracker::Record.count' do @@ -62,8 +61,8 @@ class TextileArticleTest < ActiveSupport::TestCase should 'not create trackers activity when updating articles' do ActionTracker::Record.delete_all - a1 = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true - a2 = create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true + a1 = create TextileArticle, name: 'bar', profile_id: profile.id, published: true + a2 = create TextileArticle, name: 'another bar', profile_id: profile.id, published: true assert_no_difference 'ActionTracker::Record.count' do a1.name = 'foo';a1.save! a2.name = 'another foo';a2.save! @@ -72,7 +71,7 @@ class TextileArticleTest < ActiveSupport::TestCase should 'remove activity after destroying article' do ActionTracker::Record.delete_all - a = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true + a = create TextileArticle, name: 'bar', profile_id: profile.id, published: true assert_difference 'ActionTracker::Record.count', -1 do a.destroy end @@ -80,8 +79,8 @@ class TextileArticleTest < ActiveSupport::TestCase should 'remove activity after article is destroyed' do ActionTracker::Record.delete_all - a1 = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true - a2 = create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true + a1 = create TextileArticle, name: 'bar', profile_id: profile.id, published: true + a2 = create TextileArticle, name: 'another bar', profile_id: profile.id, published: true assert_equal 2, ActionTracker::Record.count assert_difference 'ActionTracker::Record.count', -2 do a1.destroy @@ -95,20 +94,20 @@ class TextileArticleTest < ActiveSupport::TestCase p1 = Person.first community.add_member(p1) assert p1.is_member_of?(community) - article = create TextileArticle, :name => 'test', :profile_id => community.id + article = create TextileArticle, name: 'test', profile_id: community.id assert_equal article, ActionTracker::Record.last.target end should "the tracker action target be defined as the article on articles'creation in profile" do ActionTracker::Record.delete_all person = Person.first - article = create TextileArticle, :name => 'test', :profile_id => person.id + article = create TextileArticle, name: 'test', profile_id: person.id assert_equal article, ActionTracker::Record.last.target end should 'not notify activity if the article is not advertise' do ActionTracker::Record.delete_all - a = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true, :advertise => false + a = create TextileArticle, name: 'bar', profile_id: profile.id, published: true, advertise: false assert_equal true, a.published? assert_equal true, a.notifiable? assert_equal false, a.image? @@ -121,7 +120,7 @@ class TextileArticleTest < ActiveSupport::TestCase end should "the common trackable conditions return the correct value" do - a = build(TextileArticle, :profile => profile) + a = build(TextileArticle, profile: profile) a.published = a.advertise = true assert_equal true, a.published? assert_equal true, a.notifiable? @@ -139,7 +138,7 @@ class TextileArticleTest < ActiveSupport::TestCase end should 'generate proper HTML for links' do - assert_tag_in_string build_article('"Noosfero":http://noosfero.org/').to_html, :tag => 'a', :attributes => { :href => 'http://noosfero.org/' } + assert_tag_in_string build_article('"Noosfero":http://noosfero.org/').to_html, tag: 'a', attributes: { href: 'http://noosfero.org/' } end should 'not mess up with textile markup' do @@ -153,7 +152,7 @@ class TextileArticleTest < ActiveSupport::TestCase end should 'not allow Javascript on links' do - assert_no_tag_in_string build_article('').to_html, :tag => 'a', :attributes => { :href => /./, :onclick => /./ } + assert_no_tag_in_string build_article('').to_html, tag: 'a', attributes: { href: /./, onclick: /./ } end should 'allow harmless HTML' do @@ -163,11 +162,11 @@ class TextileArticleTest < ActiveSupport::TestCase end should 'use Textile markup for lead as well' do - assert_tag_in_string build_article(nil, :abstract => '"Noosfero":http://noosfero.org/').lead, :tag => 'a', :attributes => { :href => 'http://noosfero.org/' } + assert_tag_in_string build_article(nil, abstract: '"Noosfero":http://noosfero.org/').lead, tag: 'a', attributes: { href: 'http://noosfero.org/' } end should 'not allow arbitrary HTML in the lead' do - assert_not_equal '', build_article(nil, :abstract => '').lead + assert_not_equal '', build_article(nil, abstract: '').lead end should 'not add hard breaks for single line breaks' do @@ -182,7 +181,7 @@ class TextileArticleTest < ActiveSupport::TestCase protected def build_article(input = nil, options = {}) - article = build(TextileArticle, {:body => input}.merge(options)) + article = build(TextileArticle, {body: input}.merge(options)) article.valid? # trigger the xss terminate thingy article end -- libgit2 0.21.2