[noosfero/noosfero][rails4] 3 commits: rails4: fix identifier regexp
Bráulio Bhavamitra
gitlab at gitlab.com
Mon Apr 6 23:01:32 BRT 2015
Bráulio Bhavamitra pushed to rails4 at Noosfero / noosfero
Commits:
d183832e by Braulio Bhavamitra at 2015-04-06T21:40:15Z
rails4: fix identifier regexp
- - - - -
aba435f0 by Braulio Bhavamitra at 2015-04-06T21:40:42Z
rails4: add missed param
- - - - -
f3f3c821 by Braulio Bhavamitra at 2015-04-06T22:47:49Z
rails4: fix profile tests
- - - - -
8 changed files:
- app/models/article.rb
- app/models/profile.rb
- lib/noosfero/core_ext/active_record.rb
- test/factories.rb
- test/unit/enterprise_test.rb
- test/unit/environment_test.rb
- test/unit/profile_test.rb
- test/unit/uploaded_file_test.rb
Changes:
=====================================
app/models/article.rb
=====================================
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -241,7 +241,7 @@ class Article < ActiveRecord::Base
# retrieves all articles belonging to the given +profile+ that are not
# sub-articles of any other article.
- scope :top_level_for, -> {
+ scope :top_level_for, -> (profile) {
where 'parent_id is null and profile_id = ?', profile.id
}
=====================================
app/models/profile.rb
=====================================
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -178,7 +178,7 @@ class Profile < ActiveRecord::Base
validates_length_of :description, :maximum => 550, :allow_nil => true
# Valid identifiers must match this format.
- IDENTIFIER_FORMAT = /#{Noosfero.identifier_format}/
+ IDENTIFIER_FORMAT = /\A#{Noosfero.identifier_format}\Z/
# These names cannot be used as identifiers for Profiles
RESERVED_IDENTIFIERS = %w[
=====================================
lib/noosfero/core_ext/active_record.rb
=====================================
--- a/lib/noosfero/core_ext/active_record.rb
+++ b/lib/noosfero/core_ext/active_record.rb
@@ -9,10 +9,10 @@ class ActiveRecord::Base
# an ActionView instance for rendering views on models
def self.action_view
@action_view ||= begin
- view_paths = ActionController::Base.view_paths
- action_view = ActionView::Base.new view_paths
+ view_paths = ::ActionController::Base.view_paths
+ action_view = ::ActionView::Base.new view_paths
# for using Noosfero helpers inside render calls
- action_view.extend ApplicationHelper
+ action_view.extend ::ApplicationHelper
action_view
end
end
=====================================
test/factories.rb
=====================================
--- a/test/factories.rb
+++ b/test/factories.rb
@@ -89,7 +89,7 @@ module Noosfero::Factory
:password_confirmation => name.underscore
}.merge(options)
user = build(User, data)
- user.person = build(Person, person_options)
+ user.person_data = person_options
user.save!
user
end
=====================================
test/unit/enterprise_test.rb
=====================================
--- a/test/unit/enterprise_test.rb
+++ b/test/unit/enterprise_test.rb
@@ -38,7 +38,7 @@ class EnterpriseTest < ActiveSupport::TestCase
def test_has_domains
p = Enterprise.new
- assert_kind_of Array, p.domains
+ assert p.domains.empty?
end
def test_belongs_to_environment_and_has_default
=====================================
test/unit/environment_test.rb
=====================================
--- a/test/unit/environment_test.rb
+++ b/test/unit/environment_test.rb
@@ -173,7 +173,7 @@ class EnvironmentTest < ActiveSupport::TestCase
should 'have regions' do
env = fast_create(Environment)
- assert_kind_of Array, env.regions
+ assert env.regions.empty?
assert_raise ActiveRecord::AssociationTypeMismatch do
env.regions << 1
end
@@ -524,7 +524,7 @@ class EnvironmentTest < ActiveSupport::TestCase
p1= fast_create(Person, :is_template => true, :environment_id => e.id)
p2 = fast_create(Person, :environment_id => e.id)
p3 = fast_create(Person, :is_template => true, :environment_id => e.id)
- assert_equivalent [p1,p3], e.person_templates
+ assert_equivalent [p1,p3], e.person_templates
end
should 'person_templates return an empty array if there is no templates of person' do
@@ -532,7 +532,7 @@ class EnvironmentTest < ActiveSupport::TestCase
fast_create(Person, :environment_id => e.id)
fast_create(Person, :environment_id => e.id)
- assert_equivalent [], e.person_templates
+ assert_equivalent [], e.person_templates
end
should 'person_default_template return the template defined as default' do
@@ -585,7 +585,7 @@ class EnvironmentTest < ActiveSupport::TestCase
c1= fast_create(Community, :is_template => true, :environment_id => e.id)
c2 = fast_create(Community, :environment_id => e.id)
c3 = fast_create(Community, :is_template => true, :environment_id => e.id)
- assert_equivalent [c1,c3], e.community_templates
+ assert_equivalent [c1,c3], e.community_templates
end
should 'community_templates return an empty array if there is no templates of community' do
@@ -646,7 +646,7 @@ class EnvironmentTest < ActiveSupport::TestCase
e1= fast_create(Enterprise, :is_template => true, :environment_id => env.id)
e2 = fast_create(Enterprise, :environment_id => env.id)
e3 = fast_create(Enterprise, :is_template => true, :environment_id => env.id)
- assert_equivalent [e1,e3], env.enterprise_templates
+ assert_equivalent [e1,e3], env.enterprise_templates
end
should 'enterprise_templates return an empty array if there is no templates of enterprise' do
@@ -654,7 +654,7 @@ class EnvironmentTest < ActiveSupport::TestCase
fast_create(Enterprise, :environment_id => env.id)
fast_create(Enterprise, :environment_id => env.id)
- assert_equivalent [], env.enterprise_templates
+ assert_equivalent [], env.enterprise_templates
end
should 'enterprise_default_template return the template defined as default' do
=====================================
test/unit/profile_test.rb
=====================================
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -36,7 +36,7 @@ class ProfileTest < ActiveSupport::TestCase
def test_has_domains
p = Profile.new
- assert_kind_of Array, p.domains
+ assert p.domains.empty?
end
should 'be assigned to default environment if no environment is informed' do
@@ -753,7 +753,7 @@ class ProfileTest < ActiveSupport::TestCase
should 'nickname be able to be nil' do
p = Profile.new()
p.valid?
- assert_blank p.errors[:nickname]
+ assert p.errors[:nickname].blank?
end
should 'filter html from nickname' do
@@ -1341,13 +1341,13 @@ class ProfileTest < ActiveSupport::TestCase
should 'profile be valid when image is empty' do
profile = build(Profile, :image_builder => {:uploaded_data => ""})
profile.valid?
- assert_blank profile.errors[:image]
+ assert profile.errors[:image].blank?
end
should 'profile be valid when has no image' do
profile = Profile.new
profile.valid?
- assert_blank profile.errors[:image]
+ assert profile.errors[:image].blank?
end
should 'copy header and footer after create a person' do
@@ -1357,6 +1357,7 @@ class ProfileTest < ActiveSupport::TestCase
Environment.any_instance.stubs(:person_default_template).returns(template)
person = create_user_full('mytestuser').person
+ assert_equal person.environment.person_default_template, person.template
assert_equal "footer customized", person.custom_footer
assert_equal "header customized", person.custom_header
end
=====================================
test/unit/uploaded_file_test.rb
=====================================
--- a/test/unit/uploaded_file_test.rb
+++ b/test/unit/uploaded_file_test.rb
@@ -147,7 +147,7 @@ class UploadedFileTest < ActiveSupport::TestCase
should 'use name as title by default but cut down the title' do
upload = build(UploadedFile, :uploaded_data => fixture_file_upload('/files/AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.txt'))
upload.valid?
- assert_blank upload.errors[:title]
+ assert upload.errors[:title].blank?
end
should 'create thumbnails after processing jobs' do
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c3bd3ea418456d81bec981d535aa38180de5678f...f3f3c821c79d153bbcac8fbdd3ccab8581989689
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150407/11a5b729/attachment-0001.html>
More information about the Noosfero-dev
mailing list