-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
spec/jobs/decidim/forms/export_questionnaire_answers_job_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe Decidim::Forms::ExportQuestionnaireAnswersJob do | ||
subject { described_class } | ||
|
||
let!(:user) { create(:user, :admin) } | ||
let!(:title) { "The answers" } | ||
let!(:questionnaire) { create(:questionnaire) } | ||
let!(:questions) { create_list(:questionnaire_question, 3, questionnaire: questionnaire) } | ||
let!(:answers) { questions.map { |q| create(:answer, question: q, questionnaire: questionnaire) } } | ||
let!(:collection) { [answers] } | ||
|
||
describe "queue" do | ||
it "is queued to events" do | ||
expect(subject.queue_name).to eq "exports" | ||
end | ||
end | ||
|
||
describe "when everything is OK" do | ||
let(:mailer) { double :mailer } | ||
|
||
it "sends an email" do | ||
allow(Decidim::ExportMailer) | ||
.to receive(:export) | ||
.and_return(mailer) | ||
expect(mailer) | ||
.to receive(:deliver_now) | ||
|
||
subject.perform_now(user, title, collection) | ||
end | ||
end | ||
|
||
describe "when no answers" do | ||
it "doesn't send the email" do | ||
collection = [] | ||
|
||
expect(Decidim::ExportMailer) | ||
.not_to receive(:export) | ||
|
||
subject.perform_now(user, title, collection) | ||
end | ||
end | ||
|
||
describe "when no user" do | ||
it "doesn't send the email" do | ||
user = nil | ||
|
||
expect(Decidim::ExportMailer) | ||
.not_to receive(:export) | ||
|
||
subject.perform_now(user, title, collection) | ||
end | ||
end | ||
|
||
describe "when user has no email" do | ||
it "doesn't send the email" do | ||
user.update(email: "") | ||
|
||
expect(Decidim::ExportMailer) | ||
.not_to receive(:export) | ||
|
||
subject.perform_now(user, title, collection) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "WickedPdf" do | ||
it "has version 2.6.3" do | ||
expect(WickedPdf::VERSION).to eq("2.6.3") | ||
end | ||
end |