forked from otwcode/otwarchive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO3-3997 Fix for email address validation otwcode#4390 (otwcode#4565)
* AO3-3997 Catch email validation failure in import * AO3-3997 Add missing error message in invitation page * AO3-3997 more fixes for invite * AO3-3997 more fixes for import * AO3-3997 more fixes for import (2) --------- Co-authored-by: tickinginstant <[email protected]>
- Loading branch information
1 parent
7f43395
commit ff9f334
Showing
5 changed files
with
84 additions
and
22 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
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 |
---|---|---|
|
@@ -193,21 +193,67 @@ class StoryParser | |
end | ||
|
||
it "raises an exception when the external author name is not provided" do | ||
expect { | ||
expect do | ||
@sp.parse_author("", nil, "[email protected]") | ||
}.to raise_exception(StoryParser::Error) { |e| expect(e.message).to eq("No author name specified") } | ||
end.to raise_exception(StoryParser::Error, "No author name specified") | ||
end | ||
|
||
it "raises an exception when the external author email is not provided" do | ||
expect { | ||
expect do | ||
@sp.parse_author("", "Author Name", nil) | ||
}.to raise_exception(StoryParser::Error) { |e| expect(e.message).to eq("No author email specified") } | ||
end.to raise_exception(StoryParser::Error, "No author email specified") | ||
end | ||
|
||
it "raises an exception when neither the external author name nor email is provided" do | ||
expect { | ||
expect do | ||
@sp.parse_author("", nil, nil) | ||
}.to raise_exception(StoryParser::Error) { |e| expect(e.message).to eq("No author name specified\nNo author email specified") } | ||
end.to raise_exception(StoryParser::Error, "No author name specified\nNo author email specified") | ||
end | ||
|
||
it "gives the same external author object for the same email" do | ||
res1 = @sp.parse_author("", "Author Name", "[email protected]") | ||
res2 = @sp.parse_author("", "Author Name Second", "[email protected]") | ||
res3 = @sp.parse_author("", "Author!! Name!!", "[email protected]") | ||
expect(res2.external_author.id).to eq(res1.external_author.id) | ||
expect(res3.external_author.id).to eq(res1.external_author.id) | ||
expect(res1.name).to eq("Author Name") | ||
expect(res2.name).to eq("Author Name Second") | ||
end | ||
|
||
it "ignores the external author name when it is invalid" do | ||
results = @sp.parse_author("", "!!!!", "[email protected]") | ||
expect(results.name).to eq("[email protected]") | ||
expect(results.external_author.email).to eq("[email protected]") | ||
end | ||
|
||
it "ignores invalid letters in the external author name" do | ||
results = @sp.parse_author("", "Author!! Name!!", "[email protected]") | ||
expect(results.name).to eq("Author Name") | ||
expect(results.external_author.email).to eq("[email protected]") | ||
end | ||
|
||
it "raises an exception when the external author email is invalid" do | ||
expect do | ||
@sp.parse_author("", "Author Name", "not_email") | ||
end.to raise_exception(StoryParser::Error, "Email should look like an email address.") | ||
end | ||
|
||
it "raises an exception when the external author name and email are invalid" do | ||
expect do | ||
@sp.parse_author("", "!!!!", "not_email") | ||
end.to raise_exception(StoryParser::Error, "Email should look like an email address.") | ||
end | ||
|
||
it "raises an exception when the external author name is blank and email is invalid" do | ||
expect do | ||
@sp.parse_author("", "", "not_email") | ||
end.to raise_exception(StoryParser::Error, "No author name specified\nEmail should look like an email address.") | ||
end | ||
|
||
it "raises an exception when the external author name is invalid and email is blank" do | ||
expect do | ||
@sp.parse_author("", "!!!!", "") | ||
end.to raise_exception(StoryParser::Error, "No author email specified") | ||
end | ||
end | ||
|
||
|