diff --git a/app/models/profile.rb b/app/models/profile.rb index 8a0e46c..042a5ec 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -318,7 +318,9 @@ class Profile < ActiveRecord::Base end def self.is_available?(identifier, environment, profile_id=nil) - return false unless identifier =~ IDENTIFIER_FORMAT && !RESERVED_IDENTIFIERS.include?(identifier) + return false unless identifier =~ IDENTIFIER_FORMAT && + !RESERVED_IDENTIFIERS.include?(identifier) && + (NOOSFERO_CONF['exclude_profile_identifier_pattern'].blank? || identifier !~ /#{NOOSFERO_CONF['exclude_profile_identifier_pattern']}/) return true if environment.nil? profiles = environment.profiles.where(:identifier => identifier) diff --git a/config/noosfero.yml.dist b/config/noosfero.yml.dist index e4df627..0284faa 100644 --- a/config/noosfero.yml.dist +++ b/config/noosfero.yml.dist @@ -10,6 +10,7 @@ development: exception_recipients: [admin@example.com] max_upload_size: 5MB hours_until_user_activation_check: 72 + exclude_profile_identifier_pattern: index(\..*)?|home(\..*)? test: diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 8777f77..c605084 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1613,6 +1613,16 @@ class ProfileTest < ActiveSupport::TestCase assert_equal false, Profile.is_available?('identifier-test', Environment.default) end + should 'not be available if identifier match with custom exclusion pattern' do + NOOSFERO_CONF.stubs(:[]).with('exclude_profile_identifier_pattern').returns('identifier.*') + assert_equal false, Profile.is_available?('identifier-test', Environment.default) + end + + should 'be available if identifier do not match with custom exclusion pattern' do + NOOSFERO_CONF.stubs(:[]).with('exclude_profile_identifier_pattern').returns('identifier.*') + assert_equal false, Profile.is_available?('test-identifier', Environment.default) + end + should 'not have long descriptions' do long_description = 'a' * 600 profile = Profile.new -- libgit2 0.21.2