2018-12-05 19:51:30 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe Issues::ImportCsvService do
|
2018-12-05 19:51:30 -05:00
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
2022-07-04 11:10:24 -04:00
|
|
|
let(:assignee) { create(:user, username: 'csv_assignee') }
|
2020-11-05 19:09:14 -05:00
|
|
|
let(:service) do
|
2018-12-05 19:51:30 -05:00
|
|
|
uploader = FileUploader.new(project)
|
|
|
|
uploader.store!(file)
|
|
|
|
|
2020-11-05 19:09:14 -05:00
|
|
|
described_class.new(user, project, uploader)
|
2020-10-20 11:08:57 -04:00
|
|
|
end
|
|
|
|
|
2020-11-05 19:09:14 -05:00
|
|
|
include_examples 'issuable import csv service', 'issue' do
|
|
|
|
let(:issuables) { project.issues }
|
|
|
|
let(:email_method) { :import_issues_csv_email }
|
2018-12-05 19:51:30 -05:00
|
|
|
end
|
2022-07-04 11:10:24 -04:00
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
let(:file) { fixture_file_upload('spec/fixtures/csv_complex.csv') }
|
|
|
|
|
|
|
|
subject { service.execute }
|
|
|
|
|
|
|
|
it 'sets all issueable attributes and executes quick actions' do
|
|
|
|
project.add_developer(user)
|
|
|
|
project.add_developer(assignee)
|
|
|
|
|
|
|
|
expect { subject }.to change { issuables.count }.by 3
|
|
|
|
|
|
|
|
expect(issuables.reload).to include(
|
|
|
|
have_attributes(
|
|
|
|
title: 'Title with quote"',
|
|
|
|
description: 'Description',
|
|
|
|
time_estimate: 3600,
|
|
|
|
assignees: include(assignee),
|
|
|
|
due_date: Date.new(2022, 6, 28)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2018-12-05 19:51:30 -05:00
|
|
|
end
|