Merge branch 'next-minor' into develop

This commit is contained in:
Benjamin Neff 2018-03-25 08:37:11 +02:00
commit c84411ea62
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
16 changed files with 40 additions and 23 deletions

View file

@ -14,6 +14,8 @@
## Bug fixes ## Bug fixes
* Prefill conversation form on contacts page only with mutual contacts [#7744](https://github.com/diaspora/diaspora/pull/7744) * Prefill conversation form on contacts page only with mutual contacts [#7744](https://github.com/diaspora/diaspora/pull/7744)
* Fix profiles sometimes not loading properly in background tabs [#7740](https://github.com/diaspora/diaspora/pull/7740)
* Show error message when creating posts with invalid aspects [#7742](https://github.com/diaspora/diaspora/pull/7742)
## Features ## Features

View file

@ -65,7 +65,7 @@ gem "sprockets-rails", "3.2.1"
# Database # Database
group :mysql, optional: true do group :mysql, optional: true do
gem "mysql2", "0.4.9" gem "mysql2", "0.4.10"
end end
group :postgresql, optional: true do group :postgresql, optional: true do
gem "pg", "0.21.0" gem "pg", "0.21.0"

View file

@ -391,7 +391,7 @@ GEM
multi_test (0.1.2) multi_test (0.1.2)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.0.0) multipart-post (2.0.0)
mysql2 (0.4.9) mysql2 (0.4.10)
naught (1.1.0) naught (1.1.0)
nenv (0.3.0) nenv (0.3.0)
nio4r (2.1.0) nio4r (2.1.0)
@ -831,7 +831,7 @@ DEPENDENCIES
mini_magick (= 4.8.0) mini_magick (= 4.8.0)
minitest minitest
mobile-fu (= 1.4.0) mobile-fu (= 1.4.0)
mysql2 (= 0.4.9) mysql2 (= 0.4.10)
nokogiri (= 1.8.2) nokogiri (= 1.8.2)
omniauth (= 1.6.1) omniauth (= 1.6.1)
omniauth-facebook (= 4.0.0) omniauth-facebook (= 4.0.0)

View file

@ -6,7 +6,6 @@
//= link bookmarklet.js //= link bookmarklet.js
//= link mobile/bookmarklet.js //= link mobile/bookmarklet.js
//= link mobile/mobile.js //= link mobile/mobile.js
//= link templates.js
//= link error_pages.css //= link error_pages.css
//= link admin.css //= link admin.css
//= link rtl.css //= link rtl.css

View file

@ -1,7 +1,4 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
/* we need to wrap this in a document ready to ensure JST is accessible */ Handlebars.registerPartial("status-message", HandlebarsTemplates["status-message_tpl"]);
$(function(){
Handlebars.registerPartial('status-message', HandlebarsTemplates['status-message_tpl']);
});
// @license-end // @license-end

View file

@ -1,6 +1,5 @@
//= require jquery3 //= require jquery3
//= require handlebars.runtime //= require handlebars.runtime
//= require templates
//= require main //= require main
//= require fine-uploader/fine-uploader.core //= require fine-uploader/fine-uploader.core
//= require mobile/mobile //= require mobile/mobile

View file

@ -18,6 +18,7 @@
//= require jquery.autoSuggest.custom //= require jquery.autoSuggest.custom
//= require fine-uploader/fine-uploader.core //= require fine-uploader/fine-uploader.core
//= require handlebars.runtime //= require handlebars.runtime
//= require_tree ../templates
//= require posix-bracket-expressions //= require posix-bracket-expressions
//= require markdown-it //= require markdown-it
//= require markdown-it-diaspora-mention //= require markdown-it-diaspora-mention

View file

@ -1,5 +0,0 @@
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
//= require_tree ../templates

View file

@ -49,6 +49,8 @@ class StatusMessagesController < ApplicationController
format.mobile { redirect_to stream_path } format.mobile { redirect_to stream_path }
format.json { render json: PostPresenter.new(status_message, current_user), status: 201 } format.json { render json: PostPresenter.new(status_message, current_user), status: 201 }
end end
rescue StatusMessageCreationService::BadAspectsIDs
render status: 422, plain: I18n.t("status_messages.bad_aspects")
rescue StandardError => error rescue StandardError => error
handle_create_error(error) handle_create_error(error)
end end

View file

@ -9,15 +9,16 @@ class StatusMessageCreationService
def create(params) def create(params)
build_status_message(params).tap do |status_message| build_status_message(params).tap do |status_message|
load_aspects(params[:aspect_ids]) unless status_message.public?
add_attachments(status_message, params) add_attachments(status_message, params)
status_message.save status_message.save
process(status_message, params[:aspect_ids], params[:services]) process(status_message, params[:services])
end end
end end
private private
attr_reader :user attr_reader :user, :aspects
def build_status_message(params) def build_status_message(params)
public = params[:public] || false public = params[:public] || false
@ -54,13 +55,17 @@ class StatusMessageCreationService
end end
end end
def process(status_message, aspect_ids, services) def load_aspects(aspect_ids)
add_to_streams(status_message, aspect_ids) unless status_message.public @aspects = user.aspects_from_ids(aspect_ids)
raise BadAspectsIDs if aspects.empty?
end
def process(status_message, services)
add_to_streams(status_message) unless status_message.public?
dispatch(status_message, services) dispatch(status_message, services)
end end
def add_to_streams(status_message, aspect_ids) def add_to_streams(status_message)
aspects = user.aspects_from_ids(aspect_ids)
user.add_to_streams(status_message, aspects) user.add_to_streams(status_message, aspects)
status_message.photos.each {|photo| user.add_to_streams(photo, aspects) } status_message.photos.each {|photo| user.add_to_streams(photo, aspects) }
end end
@ -72,4 +77,7 @@ class StatusMessageCreationService
url: short_post_url(status_message.guid, host: AppConfig.environment.url), url: short_post_url(status_message.guid, host: AppConfig.environment.url),
service_types: receiving_services) service_types: receiving_services)
end end
class BadAspectsIDs < RuntimeError
end
end end

View file

@ -8,7 +8,7 @@
%meta{name: "viewport", content: "width=device-width, initial-scale=1"}/ %meta{name: "viewport", content: "width=device-width, initial-scale=1"}/
- content_for :javascript do - content_for :javascript do
= javascript_include_tag :main, :templates = javascript_include_tag :main
= load_javascript_locales = load_javascript_locales
= include_color_theme = include_color_theme

View file

@ -1122,6 +1122,7 @@ en:
new: new:
mentioning: "Mentioning: %{person}" mentioning: "Mentioning: %{person}"
too_long: "Please make your status message fewer than %{count} characters. Right now it is %{current_length} characters" too_long: "Please make your status message fewer than %{count} characters. Right now it is %{current_length} characters"
bad_aspects: "Provided aspects IDs aren't applicable (non-existent or not owned)"
stream_helper: stream_helper:
no_more_posts: "You have reached the end of the stream." no_more_posts: "You have reached the end of the stream."

View file

@ -132,6 +132,12 @@ describe StatusMessagesController, :type => :controller do
status_message = StatusMessage.find_by_text(text) status_message = StatusMessage.find_by_text(text)
expect(status_message.aspect_visibilities.map(&:aspect)).to match_array([@aspect1, @aspect2]) expect(status_message.aspect_visibilities.map(&:aspect)).to match_array([@aspect1, @aspect2])
end end
it "responses 422 when aspect_ids don't contain any applicable aspect identifiers" do
bad_ids = [Aspect.ids.max.next, bob.aspects.first.id]
post :create, params: status_message_hash.merge(aspect_ids: bad_ids.to_s), format: :json
expect(response.status).to eq(422)
end
end end
it "dispatches the post to the specified services" do it "dispatches the post to the specified services" do

View file

@ -29,6 +29,13 @@ describe StatusMessageCreationService do
status_message = StatusMessageCreationService.new(alice).create(params.merge(public: true)) status_message = StatusMessageCreationService.new(alice).create(params.merge(public: true))
expect(status_message.aspect_visibilities).to be_empty expect(status_message.aspect_visibilities).to be_empty
end end
it "raises exception if aspects_ids don't contain any applicable aspect identifiers" do
bad_ids = [Aspect.ids.max.next, bob.aspects.first.id].map(&:to_s)
expect {
StatusMessageCreationService.new(alice).create(params.merge(aspect_ids: bad_ids))
}.to remain(StatusMessage, :count).and raise_error(StatusMessageCreationService::BadAspectsIDs)
end
end end
context "with public" do context "with public" do

View file

@ -44,8 +44,6 @@ shared_examples_for "it removes the person associations" do
end end
shared_examples_for "it keeps the person conversations" do shared_examples_for "it keeps the person conversations" do
RSpec::Matchers.define_negated_matcher :remain, :change
it "remains the person conversations" do it "remains the person conversations" do
expect { expect {
account_removal_method account_removal_method

View file

@ -24,6 +24,8 @@ Dir["#{File.dirname(__FILE__)}/shared_behaviors/**/*.rb"].each do |f|
require f require f
end end
RSpec::Matchers.define_negated_matcher :remain, :change
ProcessedImage.enable_processing = false ProcessedImage.enable_processing = false
UnprocessedImage.enable_processing = false UnprocessedImage.enable_processing = false