demarches-normaliennes/spec/services/falsify_opendata_service_spec.rb
Christophe Robillard 6851a9ee52 falsify opendata flag for some procedures
`procedures:falsify_opendata_procedures` rake task allows to falsify
opndata flag for procedures listed in csv file given in input (with only
one column : id column)
2023-03-01 11:47:11 +01:00

43 lines
965 B
Ruby

describe FalsifyOpendataService do
before(:each) do
end
after(:each) do
end
describe '#call' do
let(:procedure1) { create(:procedure, opendata: true) }
let(:procedure2) { create(:procedure, opendata: true) }
subject { described_class.call(lines) }
context 'nominal case' do
let(:lines) do
[
{ "id" => procedure1.id },
{ "id" => procedure2.id }
]
end
it 'falsifies opendatas' do
errors = subject
expect(errors).to eq []
expect(procedure1.reload.opendata).to be_falsey
expect(procedure2.reload.opendata).to be_falsey
end
end
context 'with unknown procedure' do
let(:lines) do
[
{ "id" => procedure1.id + procedure2.id }
]
end
it 'returns errors' do
errors = subject
expect(errors).to eq ["Procedure #{procedure1.id + procedure2.id} introuvable"]
end
end
end
end