stadtratmonitor/spec/controllers/search_controller_spec.rb

38 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2020-03-09 11:27:52 +01:00
# frozen_string_literal: true
2016-02-17 08:59:52 +01:00
require 'rails_helper'
2016-02-17 20:46:03 +01:00
RSpec.describe SearchController, type: :controller, elasticsearch: true do
2020-03-09 11:27:52 +01:00
describe 'GET #index' do
it 'returns http success' do
2016-02-17 08:59:52 +01:00
get :index, body: 'leipzig'
expect(response).to have_http_status(:success)
end
2016-02-17 21:20:17 +01:00
2020-03-09 11:27:52 +01:00
it 'assigns @search_definition with default sort order' do
2016-03-30 20:55:11 +02:00
search = PaperSearch.new(sort_by: 'date')
2016-02-17 21:20:17 +01:00
get :index, body: 'leipzig'
expect(assigns(:search_definition).attributes).to eq(search.attributes)
end
2020-03-09 11:27:52 +01:00
it 'renders the index template' do
2016-02-17 21:20:17 +01:00
get :index, body: 'leipzig'
expect(response).to render_template(:index)
end
2020-03-09 11:27:52 +01:00
it 'returns rss' do
get :index, format: 'rss', body: 'leipzig'
2016-04-10 14:47:22 +02:00
expect(response).to be_success
expect(response).to render_template(:index)
2020-03-09 11:27:52 +01:00
expect(response.content_type).to eq('application/rss+xml')
# expect(response.body).to have_tag "rss" do
2016-04-10 14:48:04 +02:00
# with_tag "channel" do
# with_tag "title"
# with_tag "description"
# with_tag "link"
# end
2020-03-09 11:27:52 +01:00
# end
2016-04-10 14:47:22 +02:00
end
2016-02-17 08:59:52 +01:00
end
end