Spec for post creation bad aspects_ids issue
This commit is contained in:
parent
f632f8a1f8
commit
e0e40f73c3
5 changed files with 18 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue