<commit_before>require 'rails_helper'
require "spec_helper"

RSpec.describe "Spots", type: :request do
  describe "GET /" do
    context 'basic case' do
      before do
        create :ee_datum_with_spot, latitude:36.1, longitude:136.1
        create :ee_datum_with_spot, latitude:36.0, longitude:136
        create :ee_datum_with_spot, latitude:37.1, longitude:137.1
        create :ee_datum_with_spot, latitude:36.0, longitude:136.1, status:'closed'
      end
      it do
        get api_v1_spots_path, params:{n:37, s:35, w:135, e:137}
        expect(response).to have_http_status(200)
        expect(response.body).to include_json({
          "status": "OK",
          "results": [
            {
              "latitude": 36.0,
              "longitude": 136.0,
              "distance": (be_a_kind_of(Float))
            },
            {
              "latitude": 36.1,
              "longitude": 136.1,
              "distance": (be_a_kind_of(Float))
            }
          ]
        })
        expect(response.body).not_to include_json({
          "results": [
            {
              "latitude": 37.1,
              "longitude": 137.1,
              "status": 'closed'
            }
          ]
        })
      end
      it 'contains_invalid' do
        get api_v1_spots_path, params:{n:37, s:35, w:135, e:137, contains_invalid:true}
        expect(response.body).to include_json({
          "results": [
            {},
            {
              "latitude": 36.0,
              "longitude": 136.1,
              "status": 'closed'
            }
          ]
        })
      end
    end
    context 'tag' do
      before do
        create :ee_datum_with_spot, latitude:36.01, longitude:136, tag:'A'
        create :ee_datum_with_spot, latitude:36.02, longitude:136, tag:'A,B'
        create :ee_datum_with_spot, latitude:36.03, longitude:136, tag:'A,C'
        create :ee_datum_with_spot, latitude:36.04, longitude:136, tag:'C,D'
      end
      it do
        get api_v1_spots_path, params:{n:37, s:35, w:135, e:137, tags:'A,B'}
        Rails.logger.debug("EeDatum.count:#{EeDatum.count}")
        Rails.logger.debug("Spots.count:#{Spot.count}")
        Rails.logger.debug(response.body)
        expect(response.body).to include_json({
          "results": [
            { "tags": ['A'] },
            { "tags": ['A','B'] },
            { "tags": ['A','C'] },
          ]
        })
        expect(response.body).not_to include_json({<commit_msg>ログを削除 CircleCI failed at spec/requests/api/v1/spots_spec.rb:64 #31<commit_after>require 'rails_helper'
require "spec_helper"

RSpec.describe "Spots", type: :request do
  describe "GET /" do
    context 'basic case' do
      before do
        create :ee_datum_with_spot, latitude:36.1, longitude:136.1
        create :ee_datum_with_spot, latitude:36.0, longitude:136
        create :ee_datum_with_spot, latitude:37.1, longitude:137.1
        create :ee_datum_with_spot, latitude:36.0, longitude:136.1, status:'closed'
      end
      it do
        get api_v1_spots_path, params:{n:37, s:35, w:135, e:137}
        expect(response).to have_http_status(200)
        expect(response.body).to include_json({
          "status": "OK",
          "results": [
            {
              "latitude": 36.0,
              "longitude": 136.0,
              "distance": (be_a_kind_of(Float))
            },
            {
              "latitude": 36.1,
              "longitude": 136.1,
              "distance": (be_a_kind_of(Float))
            }
          ]
        })
        expect(response.body).not_to include_json({
          "results": [
            {
              "latitude": 37.1,
              "longitude": 137.1,
              "status": 'closed'
            }
          ]
        })
      end
      it 'contains_invalid' do
        get api_v1_spots_path, params:{n:37, s:35, w:135, e:137, contains_invalid:true}
        expect(response.body).to include_json({
          "results": [
            {},
            {
              "latitude": 36.0,
              "longitude": 136.1,
              "status": 'closed'
            }
          ]
        })
      end
    end
    context 'tag' do
      before do
        create :ee_datum_with_spot, latitude:36.01, longitude:136, tag:'A'
        create :ee_datum_with_spot, latitude:36.02, longitude:136, tag:'A,B'
        create :ee_datum_with_spot, latitude:36.03, longitude:136, tag:'A,C'
        create :ee_datum_with_spot, latitude:36.04, longitude:136, tag:'C,D'
      end
      it do
        get api_v1_spots_path, params:{n:37, s:35, w:135, e:137, tags:'A,B'}
        expect(response.body).to include_json({
          "results": [
            { "tags": ['A'] },
            { "tags": ['A','B'] },
            { "tags": ['A','C'] },
          ]
        })
        expect(response.body).not_to include_json({
{'fraction_non_alphanumeric': 0.13906185139061852, 'fraction_numerical': 0.050435865504358655, 'mean_word_length': 1.7936231884057972, 'pattern_counts': {'":': 40, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2345023', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1571, 'n_words': 287}