Skip to content
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

Improve project linking workflows API end point #3626

Merged
merged 9 commits into from
Jul 8, 2021

Conversation

camallen
Copy link
Contributor

When linking workflow(s) to a project the current behaviour is to duplicate the workflow and save a new copy. This duplicate is basic and copies over existing context and values that make little or no sense in the new project (classification counts etc) while not allowing us to copy workflow relations (e.g. translations etc)

This PR introduces a WorkflowCopier class that allows custom copying logic for the Workflow resource and copy the translation resources as well.

This WorkflowCopier class is now used instead of the basic AR .dup method in the controller action to update the link relations.

Additionally - my laptop was going crazy 'monitoring' the project files via guard (I may be the only one that uses this) so i updated the guard dependencies (improve the underlying FS libs for monitoring changes) and config (to reduce the number of files we are 'monitoring'). This massively improved the system for me and doesn't impact the behaviour of this PR just how i run my dev setup.

I realize this is an unrelated addition to the PR and if folks feel strongly i'll remove to it's own PR.

Review checklist

  • First, the most important one: is this PR small enough that you can actually review it? Feel free to just reject a branch if the changes are hard to review due to the length of the diff.
  • If there are any migrations, will they the previous version of the app work correctly after they've been run (e.g. the don't remove columns still known about by ActiveRecord).
  • If anything changed with regards to the public API, are those changes also documented in the apiary.apib file?
  • Are all the changes covered by tests? Think about any possible edge cases that might be left untested.

lib/workflow_copier.rb Show resolved Hide resolved
expect(resource.workflows.first.id).to_not eq(workflow.id)
end
end

context "copy linked subject_set" do
context 'copy linked subject_set' do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSpec/NestedGroups: Maximum example group nesting exceeded [4/3].
RSpec/ContextWording: Start context description with 'when', 'with', or 'without'.

context "copy linked workflow" do
it 'should have the same tasks workflow' do
expect(resource.workflows.first.tasks).to eq(workflow.tasks)
context 'copy linked workflow' do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSpec/NestedGroups: Maximum example group nesting exceeded [4/3].
RSpec/ContextWording: Start context description with 'when', 'with', or 'without'.

@camallen camallen requested a review from yuenmichelle1 June 18, 2021 17:05
Copy link
Collaborator

@yuenmichelle1 yuenmichelle1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants