Skip to content

Commit

Permalink
Update policies before linking to sample types
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Jul 24, 2024
1 parent 2a90c9b commit c116e8c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/controllers/isa_assays_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def new
end

def create
update_sharing_policies @isa_assay.assay
@isa_assay.sample_type.policy = @isa_assay.assay.policy
if @isa_assay.save
flash[:notice] = "The #{t('isa_assay')} was successfully created.<br/>".html_safe
Expand All @@ -67,6 +68,7 @@ def edit
end

def update
update_sharing_policies @isa_assay.assay
@isa_assay.assay.attributes = isa_assay_params[:assay]
@isa_assay.sample_type.policy = @isa_assay.assay.policy
# update the sample_type
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/isa_studies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def new

def create
@isa_study = IsaStudy.new(isa_study_params)
update_sharing_policies @isa_study.study
@isa_study.source.policy = @isa_study.study.policy
@isa_study.sample_collection.policy = @isa_study.study.policy
update_sharing_policies @isa_study.study
@isa_study.source.contributor = User.current_user.person
@isa_study.sample_collection.contributor = User.current_user.person
@isa_study.study.sample_types = [@isa_study.source, @isa_study.sample_collection]
Expand Down Expand Up @@ -44,9 +44,9 @@ def edit
def update
# update the study
@isa_study.study.attributes = isa_study_params[:study]
update_sharing_policies @isa_study.study
@isa_study.source.policy = @isa_study.study.policy
@isa_study.sample_collection.policy = @isa_study.study.policy
update_sharing_policies @isa_study.study
update_relationships(@isa_study.study, isa_study_params[:study])

# update the source
Expand Down
2 changes: 1 addition & 1 deletion test/functional/isa_assays_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def setup

end

test 'Should create the same policies for the sample types' do
test 'Should create the same policies for the sample type' do
person = FactoryBot.create(:person_not_in_project)
second_person = FactoryBot.create(:person_not_in_project)
institution = FactoryBot.create(:institution)
Expand Down

0 comments on commit c116e8c

Please sign in to comment.