Merge branch 'master' into vdom

This commit is contained in:
Sam 2016-02-18 13:20:55 +11:00
commit b11e6ec38e
6 changed files with 49 additions and 35 deletions
app
assets/javascripts/discourse/initializers
models
db/fixtures
lib
spec/components/email

View file

@ -49,34 +49,35 @@ export default {
const oldNotifications = stale.results.get('content'); const oldNotifications = stale.results.get('content');
const staleIndex = _.findIndex(oldNotifications, {id: lastNotification.id}); const staleIndex = _.findIndex(oldNotifications, {id: lastNotification.id});
if (staleIndex > -1) { if (staleIndex === -1) {
oldNotifications.splice(staleIndex, 1); // this gets a bit tricky, uread pms are bumped to front
var insertPosition = 0;
if (lastNotification.notification_type !== 6) {
insertPosition = _.findIndex(oldNotifications, function(n){
return n.notification_type !== 6 || n.read;
});
insertPosition = insertPosition === -1 ? oldNotifications.length - 1 : insertPosition;
}
oldNotifications.insertAt(insertPosition, Em.Object.create(lastNotification));
} }
// this gets a bit tricky, uread pms are bumped to front for (var idx=0; idx < data.recent.length; idx++) {
var insertPosition = 0; var old;
if (lastNotification.notification_type !== 6) { while(old = oldNotifications[idx]) {
insertPosition = _.findIndex(oldNotifications, function(n){ var info = data.recent[idx];
return n.notification_type !== 6 || n.read;
});
insertPosition = insertPosition === -1 ? oldNotifications.length - 1 : insertPosition;
}
oldNotifications.splice(insertPosition, 0, Em.Object.create(lastNotification));
var idx=0;
data.recent.forEach((info)=> {
var old = oldNotifications[idx];
if (old) {
if (old.get('id') !== info[0]) { if (old.get('id') !== info[0]) {
oldNotifications.splice(idx, 1); oldNotifications.removeAt(idx);
return; } else {
} else if (old.get('read') !== info[1]) { if (old.get('read') !== info[1]) {
old.set('read', info[1]); old.set('read', info[1]);
}
break;
} }
} }
idx += 1; if ( !old ) { break; }
}); }
} }
}, user.notification_channel_position); }, user.notification_channel_position);

View file

@ -62,7 +62,8 @@ class AdminDashboardData
:failing_emails_check, :default_logo_check, :contact_email_check, :failing_emails_check, :default_logo_check, :contact_email_check,
:send_consumer_email_check, :title_check, :send_consumer_email_check, :title_check,
:site_description_check, :site_contact_username_check, :site_description_check, :site_contact_username_check,
:notification_email_check, :subfolder_ends_in_slash_check :notification_email_check, :subfolder_ends_in_slash_check,
:pop3_polling_configuration
add_problem_check do add_problem_check do
sidekiq_check || queue_size_check sidekiq_check || queue_size_check
@ -205,4 +206,8 @@ class AdminDashboardData
I18n.t('dashboard.subfolder_ends_in_slash') if Discourse.base_uri =~ /\/$/ I18n.t('dashboard.subfolder_ends_in_slash') if Discourse.base_uri =~ /\/$/
end end
def pop3_polling_configuration
POP3PollingEnabledSettingValidator.new.error_message if SiteSetting.pop3_polling_enabled
end
end end

View file

@ -55,7 +55,7 @@ if User.exec_sql("SELECT 1 FROM schema_migration_details
automatically_unpin_topics automatically_unpin_topics
digest_after_days digest_after_days
].each do |column| ].each do |column|
User.exec_sql("ALTER TABLE users DROP column #{column}") User.exec_sql("ALTER TABLE users DROP column IF EXISTS #{column}")
end end
end end
@ -70,20 +70,18 @@ if ENV["SMOKE"] == "1"
u.username_lower = "smoke_user" u.username_lower = "smoke_user"
u.email = "smoke_user@discourse.org" u.email = "smoke_user@discourse.org"
u.password = "P4ssw0rd" u.password = "P4ssw0rd"
u.email_direct = false
u.email_digests = false
u.email_private_messages = false
u.active = true u.active = true
u.approved = true u.approved = true
u.approved_at = Time.now u.approved_at = Time.now
u.trust_level = TrustLevel[3] u.trust_level = TrustLevel[3]
end.first end.first
EmailToken.seed do |et| UserOption.where(user_id: smoke_user.id).update_all(
et.id = 1 email_direct: false,
et.user_id = smoke_user.id email_digests: false,
et.email = smoke_user.email email_private_messages: false,
et.confirmed = true )
end
EmailToken.where(user_id: smoke_user.id).update_all(confirmed: true)
end end

View file

@ -23,6 +23,10 @@ module Email
def send def send
return if SiteSetting.disable_emails return if SiteSetting.disable_emails
return if ActionMailer::Base::NullMail === @message
return if ActionMailer::Base::NullMail === (@message.message rescue nil)
return skip(I18n.t('email_log.message_blank')) if @message.blank? return skip(I18n.t('email_log.message_blank')) if @message.blank?
return skip(I18n.t('email_log.message_to_blank')) if @message.to.blank? return skip(I18n.t('email_log.message_to_blank')) if @message.to.blank?

View file

@ -23,7 +23,7 @@ class POP3PollingEnabledSettingValidator
I18n.t("site_settings.errors.pop3_polling_username_is_empty") I18n.t("site_settings.errors.pop3_polling_username_is_empty")
elsif SiteSetting.pop3_polling_password.blank? elsif SiteSetting.pop3_polling_password.blank?
I18n.t("site_settings.errors.pop3_polling_password_is_empty") I18n.t("site_settings.errors.pop3_polling_password_is_empty")
else elsif !authentication_works?
I18n.t("site_settings.errors.pop3_polling_authentication_failed") I18n.t("site_settings.errors.pop3_polling_authentication_failed")
end end
end end

View file

@ -7,7 +7,13 @@ describe Email::Sender do
SiteSetting.expects(:disable_emails).returns(true) SiteSetting.expects(:disable_emails).returns(true)
Mail::Message.any_instance.expects(:deliver_now).never Mail::Message.any_instance.expects(:deliver_now).never
message = Mail::Message.new(to: "hello@world.com" , body: "hello") message = Mail::Message.new(to: "hello@world.com" , body: "hello")
Email::Sender.new(message, :hello).send expect(Email::Sender.new(message, :hello).send).to eq(nil)
end
it "doesn't deliver mail when the message is of type NullMail" do
Mail::Message.any_instance.expects(:deliver_now).never
message = ActionMailer::Base::NullMail.new
expect(Email::Sender.new(message, :hello).send).to eq(nil)
end end
it "doesn't deliver mail when the message is nil" do it "doesn't deliver mail when the message is nil" do