-
Notifications
You must be signed in to change notification settings - Fork 10
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
Sync this repo with RuboCop GOV.UK #770
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a22340d
Remove redundant default/rails config
85b871c
Sync RSpec config with RuboCop GOV.UK
cb7ac0c
Fix RSpec/ContextWording issues
8b74075
Fix RSpec/VerifiedDoubles issues
c887a47
Fix RSpec/NamedSubject issues
2262b79
Fix RSpec/AnyInstance issues
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,17 @@ | ||
require: rubocop-rspec | ||
inherit_gem: | ||
rubocop-govuk: | ||
- "config/default.yml" | ||
- "config/rails.yml" | ||
|
||
inherit_from: .rubocop_todo.yml | ||
- "config/rspec.yml" | ||
|
||
inherit_mode: | ||
merge: | ||
- Exclude | ||
|
||
RSpec/NestedGroups: | ||
Max: 4 | ||
|
||
RSpec/MultipleExpectations: | ||
Max: 10 | ||
|
||
RSpec/ExampleLength: | ||
Enabled: false | ||
|
||
# This recently introduced cop seems to have stirred up some controversy | ||
Style/AccessModifierDeclarations: | ||
Enabled: false | ||
|
||
Layout/AccessModifierIndentation: | ||
Enabled: false | ||
|
||
RSpec/ContextWording: | ||
Enabled: false | ||
|
||
Naming/MemoizedInstanceVariableName: | ||
Enabled: false | ||
|
||
# Mongoid doesn't support some of the methods that Rubocop prefers | ||
# This isn't supported by Mongoid | ||
Rails/FindBy: | ||
Enabled: false | ||
|
||
# This isn't supported by Mongoid | ||
Rails/FindEach: | ||
Enabled: false |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,32 +1,31 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe ContentDispositionConfiguration do | ||
subject { described_class.new(type: type) } | ||
|
||
let(:config) { described_class.new(type: type) } | ||
let(:type) { "inline" } | ||
let(:asset) { FactoryBot.build(:asset) } | ||
|
||
describe "#type" do | ||
let(:type) { "attachment" } | ||
|
||
it "returns type supplied to constructor" do | ||
expect(subject.type).to eq("attachment") | ||
expect(config.type).to eq("attachment") | ||
end | ||
end | ||
|
||
describe "#options_for" do | ||
it "returns options including filename for asset" do | ||
expect(subject.options_for(asset)).to include(filename: "asset.png") | ||
expect(config.options_for(asset)).to include(filename: "asset.png") | ||
end | ||
|
||
it "returns options including disposition for asset" do | ||
expect(subject.options_for(asset)).to include(disposition: "inline") | ||
expect(config.options_for(asset)).to include(disposition: "inline") | ||
end | ||
end | ||
|
||
describe "#header_for" do | ||
it "returns Content-Disposition header value" do | ||
expect(subject.header_for(asset)).to eq(%(inline; filename="asset.png")) | ||
expect(config.header_for(asset)).to eq(%(inline; filename="asset.png")) | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 saw from the commit message about switching this to a 500 which makes sense, what I wondered is whether we're confident this definitely produces a 500?
If this was ActiveRecord the
ActiveRecord::RecordInvalid
exception would be caught and converted to a 422 by action_dispatch.rescue_responses by default and it looks like Mongoid applies the same in a Railtie: https://github.com/mongodb/mongoid/blob/3cbbcfb42b091261f7f255959c48d98a1b5948cb/lib/mongoid/railtie.rb#L26There 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.
That's true. I was naively assuming that most records would be valid, and the text in the (now) deleted test suggested the developer was more concerned about a scenario where the DB operation itself failed, although admittedly that wouldn't populate
errors
!How about I rephrase the commit to be more: it'll do the right thing without us testing it?
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.
Oh so sorry for the long delay.
The commit message change sounds reasonable, every other route I consider seems to end up in massive rabbit hole. It may mean a client gets a 422 in an unexpected format, but then no-one can do anything about a 422 here as it's the system state that is wrong (and thus the rabbit hole).