-
Notifications
You must be signed in to change notification settings - Fork 5
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
357 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'test_helper' | ||
|
||
class AdminMailerTest < ActionMailer::TestCase | ||
def setup | ||
ActionMailer::Base.default_options = { from: 'noreply@example.com' } | ||
end | ||
|
||
test "image_states" do | ||
rake_results = { | ||
"Institution A" => { success: 10, failure: 2 }, | ||
"Institution B" => { success: 15, failure: 0 } | ||
} | ||
|
||
email = AdminMailer.image_states(rake_results) | ||
|
||
assert_emails 1 do | ||
email.deliver_now | ||
end | ||
|
||
assert_equal ['geoportal@btaa.org', 'majew030@umn.edu', 'ewlarson@gmail.com', 'mjb@umn.edu'], email.to | ||
assert_equal 'noreply@example.com', email.from[0] | ||
assert_equal 'B1G GeoBOT - Image Harvest States', email.subject | ||
assert_match 'Institution A', email.body.to_s | ||
assert_match 'Institution B', email.body.to_s | ||
assert_match ':success=>10', email.body.to_s | ||
assert_match ':failure=>2', email.body.to_s | ||
assert_match ':success=>15', email.body.to_s | ||
assert_match ':failure=>0', email.body.to_s | ||
end | ||
|
||
test "uri_analysis" do | ||
report_file_path = '/path/to/uri_analysis_report.csv' | ||
|
||
email = AdminMailer.uri_analysis(report_file_path) | ||
|
||
assert_emails 1 do | ||
email.deliver_now | ||
end | ||
|
||
assert_equal ['geoportal@btaa.org', 'majew030@umn.edu', 'ewlarson@gmail.com', 'mjb@umn.edu'], email.to | ||
assert_equal 'noreply@example.com', email.from[0] | ||
assert_equal 'B1G GeoBOT - URI Analysis Report', email.subject | ||
assert_match report_file_path, email.body.to_s | ||
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,60 @@ | ||
require 'test_helper' | ||
|
||
class ExportTableauServiceTest < ActiveSupport::TestCase | ||
setup do | ||
@document1 = Struct.new(:title, :geomg_id_s).new( | ||
title: "Document 1", | ||
geomg_id_s: "doc1" | ||
) | ||
|
||
@document2 = Struct.new(:title, :geomg_id_s).new( | ||
title: "Document 2", | ||
geomg_id_s: "doc2" | ||
) | ||
end | ||
|
||
test "call method returns correct CSV data" do | ||
result = ExportTableauService.call | ||
|
||
expected_header = [ | ||
"Title", | ||
"Provider", | ||
"Resource Class", | ||
"Resource Type", | ||
"Index Year", | ||
"Spatial Coverage", | ||
"B1G Image", | ||
"ID", | ||
"Download", | ||
"Language" | ||
] | ||
|
||
assert_equal expected_header, result[0] | ||
assert_includes result, ["Document 1", nil, nil, nil, nil, nil, nil, "doc1", nil, nil] | ||
assert_includes result, ["Document 2", nil, nil, nil, nil, nil, nil, "doc2", nil, nil] | ||
end | ||
|
||
test "call method broadcasts progress" do | ||
broadcasts = [] | ||
|
||
ActionCable.server.define_singleton_method(:broadcast) do |channel, message| | ||
broadcasts << [channel, message] | ||
end | ||
|
||
debugger | ||
|
||
# 1 | ||
ExportTableauService.call | ||
# 2 | ||
ExportTableauService.call | ||
# 3 | ||
ExportTableauService.call | ||
|
||
debugger | ||
|
||
assert_equal 3, broadcasts.size | ||
assert_equal ["export_channel", {progress: 0}], broadcasts.first | ||
ensure | ||
ActionCable.server.singleton_class.remove_method(:broadcast) if ActionCable.server.singleton_class.method_defined?(:broadcast) | ||
end | ||
end |
Oops, something went wrong.