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

View File

@ -49,34 +49,35 @@ export default {
const oldNotifications = stale.results.get('content');
const staleIndex = _.findIndex(oldNotifications, {id: lastNotification.id});
if (staleIndex > -1) {
oldNotifications.splice(staleIndex, 1);
if (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
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;
}
for (var idx=0; idx < data.recent.length; idx++) {
var old;
while(old = oldNotifications[idx]) {
var info = data.recent[idx];
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]) {
oldNotifications.splice(idx, 1);
return;
} else if (old.get('read') !== info[1]) {
old.set('read', info[1]);
oldNotifications.removeAt(idx);
} else {
if (old.get('read') !== info[1]) {
old.set('read', info[1]);
}
break;
}
}
idx += 1;
});
if ( !old ) { break; }
}
}
}, user.notification_channel_position);

View File

@ -62,7 +62,8 @@ class AdminDashboardData
:failing_emails_check, :default_logo_check, :contact_email_check,
:send_consumer_email_check, :title_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
sidekiq_check || queue_size_check
@ -205,4 +206,8 @@ class AdminDashboardData
I18n.t('dashboard.subfolder_ends_in_slash') if Discourse.base_uri =~ /\/$/
end
def pop3_polling_configuration
POP3PollingEnabledSettingValidator.new.error_message if SiteSetting.pop3_polling_enabled
end
end

View File

@ -55,7 +55,7 @@ if User.exec_sql("SELECT 1 FROM schema_migration_details
automatically_unpin_topics
digest_after_days
].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
@ -70,20 +70,18 @@ if ENV["SMOKE"] == "1"
u.username_lower = "smoke_user"
u.email = "smoke_user@discourse.org"
u.password = "P4ssw0rd"
u.email_direct = false
u.email_digests = false
u.email_private_messages = false
u.active = true
u.approved = true
u.approved_at = Time.now
u.trust_level = TrustLevel[3]
end.first
EmailToken.seed do |et|
et.id = 1
et.user_id = smoke_user.id
et.email = smoke_user.email
et.confirmed = true
end
UserOption.where(user_id: smoke_user.id).update_all(
email_direct: false,
email_digests: false,
email_private_messages: false,
)
EmailToken.where(user_id: smoke_user.id).update_all(confirmed: true)
end

View File

@ -23,6 +23,10 @@ module Email
def send
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_to_blank')) if @message.to.blank?

View File

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

View File

@ -7,7 +7,13 @@ describe Email::Sender do
SiteSetting.expects(:disable_emails).returns(true)
Mail::Message.any_instance.expects(:deliver_now).never
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
it "doesn't deliver mail when the message is nil" do