Commit e0e40f73 authored by Senya's avatar Senya Committed by Benjamin Neff

Spec for post creation bad aspects_ids issue

parent f632f8a1
......@@ -72,4 +72,7 @@ class StatusMessageCreationService
url: short_post_url(status_message.guid, host: AppConfig.environment.url),
service_types: receiving_services)
end
class BadAspectsIDs < RuntimeError
end
end
......@@ -132,6 +132,12 @@ describe StatusMessagesController, :type => :controller do
status_message = StatusMessage.find_by_text(text)
expect(status_message.aspect_visibilities.map(&:aspect)).to match_array([@aspect1, @aspect2])
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
it "dispatches the post to the specified services" do
......
......@@ -29,6 +29,13 @@ describe StatusMessageCreationService do
status_message = StatusMessageCreationService.new(alice).create(params.merge(public: true))
expect(status_message.aspect_visibilities).to be_empty
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
context "with public" do
......
......@@ -44,8 +44,6 @@ shared_examples_for "it removes the person associations" do
end
shared_examples_for "it keeps the person conversations" do
RSpec::Matchers.define_negated_matcher :remain, :change
it "remains the person conversations" do
expect {
account_removal_method
......
......@@ -24,6 +24,8 @@ Dir["#{File.dirname(__FILE__)}/shared_behaviors/**/*.rb"].each do |f|
require f
end
RSpec::Matchers.define_negated_matcher :remain, :change
ProcessedImage.enable_processing = false
UnprocessedImage.enable_processing = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment