Skip to content

Commit

Permalink
Merge branch 'development' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Oct 12, 2023
2 parents f07830c + 37408c5 commit 08471cd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def populate_from_params(obj, params)
# Deal with empty strings for String and URI
empty_string = value.is_a?(String) && value.empty?
old_string_value_exists = obj.respond_to?(attribute) && (obj.send(attribute).is_a?(String) || obj.send(attribute).is_a?(RDF::URI))
old_string_value_exists = old_string_value_exists || (obj.respond_to?(attribute) && obj.send(attribute).is_a?(LinkedData::Models::Base))
if old_string_value_exists && empty_string
value = nil
elsif empty_string
Expand Down Expand Up @@ -63,7 +64,7 @@ def populate_from_params(obj, params)
# Replace the initial value with the object, handling Arrays as appropriate
if value.is_a?(Array)
value = value.map {|e| attr_cls.find(uri_as_needed(e)).include(attr_cls.attributes).first}
else
elsif !value.nil?
value = attr_cls.find(uri_as_needed(value)).include(attr_cls.attributes).first
end
elsif attr_cls
Expand Down
26 changes: 26 additions & 0 deletions test/controllers/test_ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,32 @@ def test_download_acl_only
end


def test_detach_a_view
view = Ontology.find(@@view_acronym).include(:viewOf).first
ont = view.viewOf
refute_nil view
refute_nil ont

remove_view_of = {viewOf: ''}
patch "/ontologies/#{@@view_acronym}", MultiJson.dump(remove_view_of), "CONTENT_TYPE" => "application/json"

assert last_response.status == 204

get "/ontologies/#{@@view_acronym}"
onto = MultiJson.load(last_response.body)
assert_nil onto["viewOf"]


add_view_of = {viewOf: @@acronym}
patch "/ontologies/#{@@view_acronym}", MultiJson.dump(add_view_of), "CONTENT_TYPE" => "application/json"

assert last_response.status == 204

get "/ontologies/#{@@view_acronym}"
onto = MultiJson.load(last_response.body)
assert_equal onto["viewOf"], ont.id.to_s
end

private

def check400(response)
Expand Down

0 comments on commit 08471cd

Please sign in to comment.