@filter @image @project
Feature: Filters

  <% @formatter.get_fixture('providers/without_static').each do |provider| %>
  <% image = @formatter.get_fixture(provider + "/image")["id"] %>
  <% generate_401_406_415 "Delete #{provider} image filter", "POST", "/v3/filter/#{provider}/images/delete", [ image ], provider %>

  <% ["", "{}"].each do |body| %>
  @<%= provider %>
  Scenario: Delete <%= provider %> image filter, invalid body: empty
    When I send POST '/v3/filter/<%= provider %>/images/delete' query with JSON body
    """
    <%= body %>
    """
    Then response should be '400'

  <% end %>

  <% ["[{}]", "[[]]", "[null]"].each do |body| %>
  @<%= provider %>
  Scenario: Delete <%= provider %> image filter, invalid body: empty
    When I send POST '/v3/filter/<%= provider %>/images/delete' query with JSON body
    """
    <%= body %>
    """
    Then response should be '422'

  <% end %>

  @<%= provider %>
  Scenario: Delete <%= provider %> image filter
    When I send POST '/v3/filter/<%= provider %>/images/delete' query with JSON body
    """
    [
      "<%= image %>"
    ]
    """
    Then response should be '200'
    And the Content-Type header should include 'application/json'
    And the JSON response should be an object
    And the object should contains key 'images' with array and array should not contains strings '<%= image %>'

  @<%= provider %>
  Scenario: Get new (after delete) <%= provider %> image filter and check value '<%= image %>'
    When I send GET '/v3/filter/<%= provider %>/images' query
    Then response should be '200'
    And the Content-Type header should include 'application/json'
    And the JSON response should be an array
    And the array should not contains strings '<%= image %>'

  <% end %>
