Commit 2e81bdc6a537fe2b6e6393814308cc751aa82aa1

Authored by Antonio Terceiro
2 parents 1b1da66a daa97893

Merge branch 'master' into next

app/models/user.rb
... ... @@ -159,6 +159,7 @@ class User < ActiveRecord::Base
159 159 @task.name = self.name
160 160 @task.email = self.email
161 161 @task.target = self.environment
  162 + @task.requestor = self.person
162 163 @task.save
163 164 end
164 165  
... ... @@ -301,6 +302,10 @@ class User < ActiveRecord::Base
301 302 end
302 303 end
303 304  
  305 + def moderate_registration_pending?
  306 + return ModerateUserRegistration.exists?(:requestor_id => self.person.id, :target_id => self.environment.id, :status => Task::Status::ACTIVE)
  307 + end
  308 +
304 309 def data_hash(gravatar_default = nil)
305 310 friends_list = {}
306 311 enterprises = person.enterprises.map { |e| { 'name' => e.short_name, 'identifier' => e.identifier } }
... ...
app/views/layouts/application-ng.html.erb
... ... @@ -6,6 +6,10 @@
6 6 <!--<meta http-equiv="refresh" content="1"/>-->
7 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8 8  
  9 + <% unless defined? MetadataPlugin and environment.enabled_plugins.include? 'MetadataPlugin' %>
  10 + <meta name="description" content="<%= @environment.name %>" />
  11 + <% end %>
  12 +
9 13 <!-- site root -->
10 14 <meta property="noosfero:root" content="<%= Noosfero.root %>"/>
11 15  
... ...
lib/user_activation_job.rb
1 1 class UserActivationJob < Struct.new(:user_id)
2 2 def perform
3 3 user = User.find(user_id)
4   - user.destroy unless user.activated? || user.person.is_template?
  4 + user.destroy unless user.activated? || user.person.is_template? || user.moderate_registration_pending?
5 5 end
6 6 end
... ...
plugins/metadata/lib/ext/environment.rb
... ... @@ -2,6 +2,10 @@ require_dependency &#39;environment&#39;
2 2  
3 3 class Environment
4 4  
  5 + metadata_spec tags: {
  6 + description: proc{ |e, plugin| e.name },
  7 + }
  8 +
5 9 metadata_spec namespace: :og, tags: {
6 10 type: 'website',
7 11 title: proc{ |e, plugin| e.name },
... ...
plugins/pg_search/db/migrate/20130320010063_create_indexes_for_search.rb
1 1 class CreateIndexesForSearch < ActiveRecord::Migration
  2 + SEARCHABLES = %w[ article comment qualifier national_region certifier profile license scrap category ]
  3 + KLASSES = SEARCHABLES.map {|searchable| searchable.camelize.constantize }
2 4 def self.up
3   - searchables = %w[ article comment qualifier national_region certifier profile license scrap category ]
4   - klasses = searchables.map {|searchable| searchable.camelize.constantize }
5   - klasses.each do |klass|
  5 + KLASSES.each do |klass|
6 6 fields = klass.pg_search_plugin_fields
7 7 execute "create index pg_search_plugin_#{klass.name.singularize.downcase} on #{klass.table_name} using gin(to_tsvector('simple', #{fields}))"
8 8 end
9 9 end
10 10  
11 11 def self.down
12   - klasses.each do |klass|
  12 + KLASSES.each do |klass|
13 13 execute "drop index pg_search_plugin_#{klass.name.singularize.downcase}"
14 14 end
15 15 end
... ...
public/javascripts/application.js
... ... @@ -1064,7 +1064,7 @@ jQuery(document).ready(function(){
1064 1064 function apply_zoom_to_images(zoom_text) {
1065 1065 jQuery(function($) {
1066 1066 $(window).load( function() {
1067   - $('#article .article-body img').each( function(index) {
  1067 + $('#article .article-body img:not(.disable-zoom)').each( function(index) {
1068 1068 var original = original_image_dimensions($(this).attr('src'));
1069 1069 if ($(this).width() < original['width'] || $(this).height() < original['height']) {
1070 1070 $(this).wrap('<div class="zoomable-image" />');
... ...
test/unit/user_activation_job_test.rb
... ... @@ -40,6 +40,18 @@ class UserActivationJobTest &lt; ActiveSupport::TestCase
40 40 end
41 41 end
42 42  
  43 + should 'not destroy user if a moderate user registration task exists' do
  44 + env = Environment.default
  45 + env.enable('skip_new_user_email_confirmation')
  46 + env.enable('admin_must_approve_new_users')
  47 + user = new_user :login => 'test3'
  48 + job = UserActivationJob.new(user.id)
  49 + assert_no_difference 'User.count' do
  50 + job.perform
  51 + process_delayed_job_queue
  52 + end
  53 + end
  54 +
43 55 protected
44 56 def new_user(options = {})
45 57 user = User.new({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options))
... ...
test/unit/user_test.rb
... ... @@ -302,6 +302,17 @@ class UserTest &lt; ActiveSupport::TestCase
302 302 assert !user.email_activation_pending?
303 303 end
304 304  
  305 + should 'has moderate registration pending' do
  306 + user = create_user('cooler')
  307 + ModerateUserRegistration.create!(:requestor => user.person, :target => Environment.default)
  308 + assert user.moderate_registration_pending?
  309 + end
  310 +
  311 + should 'not has moderate registration pending if not have a pending task' do
  312 + user = create_user('cooler')
  313 + assert !user.moderate_registration_pending?
  314 + end
  315 +
305 316 should 'be able to use [] operator to find users by login' do
306 317 user = fast_create(User)
307 318 assert_equal user, User[user.login]
... ...