-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-3997 Fix for email address validation #4390 #4565
Changes from 4 commits
112ae8c
2de6037
7885c14
fa60bde
04c0878
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
res3 = @sp.parse_author("", "Author!! Name!!", "[email protected]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
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]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
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]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
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("", "!!!!", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible). |
||
end.to raise_exception(StoryParser::Error, "No author email specified") | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RSpec/InstanceVariable: Avoid instance variables – use let, a method call, or a local variable (if possible).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to replace the instance variable with
let
. Not sure if it's a good idea to do it now, because that would be an unrelated refactoring that would touch most of the methods here.