-
Notifications
You must be signed in to change notification settings - Fork 193
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
Add LiquidAssignsService #1205
Add LiquidAssignsService #1205
Conversation
result['evidences'] = project.evidence.map { |evidence| EvidenceDrop.new(evidence) } | ||
result['tags'] = project.tags.map { |tag| TagDrop.new(tag) } | ||
|
||
if defined?(Dradis::Pro) |
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.
What about passing in kwargs instead?
Ex.
@team = args.fetch(:team, nil)
in the initializer, and
result['team'] = TeamDrop.new(project.team) if team
on L19
to remove the need for the Dradis::Pro check
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 like that better than the Dradis::Pro
check but listing all the args sort of defeats the convenience this brings for the caller. If a caller has to instantiate the class with the following:
LiquidAssignsService.new(
project: project,
team: project.team,
document_properties: project.content_library.properties
)
Then it starts to look like:
result['project'] = ...
result['document_properties'] = ...
result['team'] = ...
just without the drop?
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'd extract this to a #assigns_pro
that only gets called if defined?
as we do in other places.
@@ -61,6 +61,11 @@ | |||
|
|||
expect do | |||
visit project_trash_path(current_project) | |||
|
|||
within '#trash' do |
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.
A bit unrelated to the task but it makes this specific spec not dependent on the other specs that create records by counting the records in the trash instead of expecting it to be empty.
Spec
Right now, we're creating liquid_assigns in a controller concern, and when we need liquid_assigns outside of a controller, we're manually creating the hash.
Proposed solution
Implement a LiquidAssignsService class to build a hash for liquid_assigns based on the given project.
Other Information
If there's anything else that's important and relevant to your pull
request, mention that information here. This could include
benchmarks, or other information.
Thanks for contributing to Dradis!
Copyright assignment
Collaboration is difficult with commercial closed source but we want
to keep as much of the OSS ethos as possible available to users
who want to fix it themselves.
In order to unambiguously own and sell Dradis Framework commercial
products, we must have the copyright associated with the entire
codebase. Any code you create which is merged must be owned by us.
That's not us trying to be a jerks, that's just the way it works.
Please review the CONTRIBUTING.md
file for the details.
You can delete this section, but the following sentence needs to
remain in the PR's description:
Check List