-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #934 from thecartercenter/12389_export_forms
12389 export form ODK XML for easier Collect import
- Loading branch information
Showing
8 changed files
with
101 additions
and
1 deletion.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
require "fileutils" | ||
require "zip" | ||
|
||
feature "form export" do | ||
context "single form" do | ||
let(:user) { create(:user, role_name: "coordinator") } | ||
let(:form) { create(:form, :live, question_types: %w[text]) } | ||
|
||
before do | ||
login(user) | ||
ODK::FormRenderJob.perform_now(form) | ||
end | ||
|
||
it "XML exports successfully" do | ||
visit(form_path(form, locale: "en", mode: "m", mission_name: get_mission.compact_name)) | ||
click_link("Export XML") | ||
expect(page.body).to match("<h:title>#{form.name}</h:title>") | ||
end | ||
end | ||
|
||
context "multiple forms" do | ||
let(:user) { create(:user, role_name: "coordinator") } | ||
let(:form1) { create(:form, :live, question_types: %w[text]) } | ||
let(:form2) { create(:form, :draft, question_types: %w[text]) } # Draft should not be exported | ||
let(:form3) { create(:form, :paused, question_types: %w[text]) } | ||
|
||
before do | ||
login(user) | ||
ODK::FormRenderJob.perform_now(form1) | ||
ODK::FormRenderJob.perform_now(form3) | ||
end | ||
|
||
it "XML exports successfully" do | ||
visit(forms_path(locale: "en", mode: "m", mission_name: get_mission.compact_name)) | ||
click_link("Export XML") | ||
|
||
Zip::File.open_buffer(page.body) do |zipfile| | ||
expect(zipfile.count).to be(2) | ||
zipfile.each do |file| | ||
expect(file.get_input_stream.read).to match("<h:title>.+</h:title>") | ||
end | ||
end | ||
end | ||
end | ||
end |