mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Fix specs
This commit is contained in:
parent
866b10ceca
commit
463e8e6d9b
3 changed files with 12 additions and 25 deletions
|
|
@ -9,7 +9,8 @@ class ExportsController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
export_name = "export_from_#{params[:start_at].to_date}_to_#{params[:end_at].to_date}.#{params[:file_format]}"
|
||||
export_name =
|
||||
"export_from_#{params[:start_at].to_date}_to_#{params[:end_at].to_date}.#{params[:file_format]}"
|
||||
export = current_user.exports.create(name: export_name, status: :created)
|
||||
|
||||
ExportJob.perform_later(export.id, params[:start_at], params[:end_at], file_format: params[:file_format])
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ RSpec.describe '/visits', type: :request do
|
|||
it 'returns confirmed visits' do
|
||||
get visits_url
|
||||
|
||||
expect(@controller.instance_variable_get(:@visits).map do |v|
|
||||
v[:visits]
|
||||
end.flatten).to match_array(confirmed_visits)
|
||||
expect(@controller.instance_variable_get(:@visits)).to match_array(confirmed_visits)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -36,17 +34,13 @@ RSpec.describe '/visits', type: :request do
|
|||
it 'does not return suggested visits' do
|
||||
get visits_url
|
||||
|
||||
expect(@controller.instance_variable_get(:@visits).map do |v|
|
||||
v[:visits]
|
||||
end.flatten).not_to include(suggested_visits)
|
||||
expect(@controller.instance_variable_get(:@visits)).not_to include(suggested_visits)
|
||||
end
|
||||
|
||||
it 'returns suggested visits' do
|
||||
get visits_url, params: { status: 'suggested' }
|
||||
|
||||
expect(@controller.instance_variable_get(:@visits).map do |v|
|
||||
v[:visits]
|
||||
end.flatten).to match_array(suggested_visits)
|
||||
expect(@controller.instance_variable_get(:@visits)).to match_array(suggested_visits)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -56,17 +50,13 @@ RSpec.describe '/visits', type: :request do
|
|||
it 'does not return declined visits' do
|
||||
get visits_url
|
||||
|
||||
expect(@controller.instance_variable_get(:@visits).map do |v|
|
||||
v[:visits]
|
||||
end.flatten).not_to include(declined_visits)
|
||||
expect(@controller.instance_variable_get(:@visits)).not_to include(declined_visits)
|
||||
end
|
||||
|
||||
it 'returns declined visits' do
|
||||
get visits_url, params: { status: 'declined' }
|
||||
|
||||
expect(@controller.instance_variable_get(:@visits).map do |v|
|
||||
v[:visits]
|
||||
end.flatten).to match_array(declined_visits)
|
||||
expect(@controller.instance_variable_get(:@visits)).to match_array(declined_visits)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -76,17 +66,13 @@ RSpec.describe '/visits', type: :request do
|
|||
it 'does not return suggested visits' do
|
||||
get visits_url
|
||||
|
||||
expect(@controller.instance_variable_get(:@visits).map do |v|
|
||||
v[:visits]
|
||||
end.flatten).not_to include(suggested_visits)
|
||||
expect(@controller.instance_variable_get(:@visits)).not_to include(suggested_visits)
|
||||
end
|
||||
|
||||
it 'returns suggested visits' do
|
||||
get visits_url, params: { status: 'suggested' }
|
||||
|
||||
expect(@controller.instance_variable_get(:@visits).map do |v|
|
||||
v[:visits]
|
||||
end.flatten).to match_array(suggested_visits)
|
||||
expect(@controller.instance_variable_get(:@visits)).to match_array(suggested_visits)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ RSpec.describe Exports::Create do
|
|||
let(:user) { create(:user) }
|
||||
let(:start_at) { DateTime.new(2021, 1, 1).to_s }
|
||||
let(:end_at) { DateTime.new(2021, 1, 2).to_s }
|
||||
let(:export_name) { "#{start_at.to_date}_#{end_at.to_date}" }
|
||||
let(:export_name) { "#{start_at.to_date}_#{end_at.to_date}.#{file_format}" }
|
||||
let(:export) { create(:export, user:, name: export_name, status: :created) }
|
||||
let(:export_content) { Points::GeojsonSerializer.new(points).call }
|
||||
let(:reverse_geocoded_at) { Time.zone.local(2021, 1, 1) }
|
||||
|
|
@ -30,10 +30,10 @@ RSpec.describe Exports::Create do
|
|||
expect(File.read(file_path).strip).to eq(export_content)
|
||||
end
|
||||
|
||||
it 'updates the export url' do
|
||||
it 'sets the export url' do
|
||||
create_export
|
||||
|
||||
expect(export.reload.url).to eq("exports/#{export.name}.json")
|
||||
expect(export.reload.url).to eq("exports/#{export.name}")
|
||||
end
|
||||
|
||||
it 'updates the export status to completed' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue