Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>
end
def update
- updated_attr = params[:collection].each.select {|a| a[0].andand.start_with? 'rename-file-path:'}
+ updated_attr = params[:collection].to_unsafe_hash.each.select {|a| a[0].andand.start_with? 'rename-file-path:'}
if updated_attr.size > 0
# Is it file rename?
include ActiveModel::Conversion
include ActiveModel::Serialization
include ActiveModel::Dirty
+ include ActiveModel::AttributeAssignment
extend ActiveModel::Naming
Column = Struct.new("Column", :name)
raise ArvadosBase::Error.new("Type unknown: #{sql_type}")
end
define_method "#{name}=" do |val|
- casted_value = caster.new.cast(val || default)
+ val = default if val.nil?
+ casted_value = caster.new.cast(val)
attribute_will_change!(name) if send(name) != casted_value
set_attribute_after_cast(name, casted_value)
end
end
def [](attr_name)
- send(attr_name)
+ begin
+ send(attr_name)
+ rescue
+ nil
+ end
end
def []=(attr_name, attr_val)
# The following permit! is necessary even with
# "ActionController::Parameters.permit_all_parameters = true",
# because permit_all does not permit nested attributes.
- if raw_params.is_a? ActionController::Parameters
- raw_params = raw_params.to_unsafe_h
+ if !raw_params.is_a? ActionController::Parameters
+ raw_params = ActionController::Parameters.new(raw_params)
end
- ActionController::Parameters.new(raw_params).permit!
+ raw_params.permit!
end
def self.create raw_params={}, create_params={}
- x = super(permit_attribute_params(raw_params))
- x.create_params = create_params
+ x = new(permit_attribute_params(raw_params), create_params)
+ x.save
x
end
+ def self.table_name
+ self.name.underscore.pluralize.downcase
+ end
+
def update_attributes raw_params={}
- super(self.class.permit_attribute_params(raw_params))
+ assign_attributes(self.class.permit_attribute_params(raw_params))
+ save
+ end
+
+ def update_attributes! raw_params={}
+ assign_attributes(self.class.permit_attribute_params(raw_params))
+ save!
end
def save
self.save or raise Exception.new("Save failed")
end
+ def persisted?
+ (!new_record? && !destroyed?) ? true : false
+ end
+
+ def destroyed?
+ !(etag || uuid)
+ end
+
def destroy
if etag || uuid
postdata = { '_method' => 'DELETE' }
<% else %>
data-object-uuid="<%= @object.uuid %>"
<% end %>
- data-pane-content-url="<%= url_for(params.merge(tab_pane: pane_name)) %>"
+ data-pane-content-url="<%= url_for(params.permit!.merge(tab_pane: pane_name)) %>"
style="margin-top:0.5em;"
>
<div class="pane-content">
<% content_for :tab_line_buttons do %>
<div class="pane-loaded arv-log-event-listener arv-refresh-on-state-change"
- data-pane-content-url="<%= url_for(params.merge(tab_pane: "job_buttons")) %>"
+ data-pane-content-url="<%= url_for(params.permit!.merge(tab_pane: "job_buttons")) %>"
data-object-uuid="<%= @object.uuid %>"
style="display: inline">
<%= render partial: 'show_job_buttons', locals: {object: @object}%>
<div id="pipeline-instance-tab-buttons"
class="pane-loaded arv-log-event-listener arv-refresh-on-state-change"
- data-pane-content-url="<%= url_for(params.merge(tab_pane: "tab_buttons")) %>"
+ data-pane-content-url="<%= url_for(params.permit!.merge(tab_pane: "tab_buttons")) %>"
data-object-uuid="<%= @object.uuid %>"
>
<%= render partial: 'show_tab_buttons', locals: {object: @object}%>
show_collection(fixture_name, :active)
fixture = api_fixture('collections')[fixture_name.to_s]
assert_equal(fixture['name'], assigns(:object).name)
- assert_equal(fixture['properties'][0], assigns(:object).properties[0])
+ assert_equal(fixture['properties'].values[0], assigns(:object).properties.values[0])
end
test "create collection with properties" do
assert_not_nil copied_cr
assert_equal 'Uncommitted', copied_cr[:state]
assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
- assert_equal completed_cr['cmd'], copied_cr['cmd']
assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
if reuse_enabled
assert copied_cr[:use_existing]
test_apps/workbench_units() {
cd "$WORKSPACE/apps/workbench" \
- && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec bin/rails test:units TESTOPTS='-v -d' ${testargs[apps/workbench]} ${testargs[apps/workbench_units]}
+ && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:units TESTOPTS='-v -d' ${testargs[apps/workbench]} ${testargs[apps/workbench_units]}
}
test_apps/workbench_functionals() {
cd "$WORKSPACE/apps/workbench" \
- && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec bin/rails test:functionals TESTOPTS='-v -d' ${testargs[apps/workbench]} ${testargs[apps/workbench_functionals]}
+ && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:functionals TESTOPTS='-v -d' ${testargs[apps/workbench]} ${testargs[apps/workbench_functionals]}
}
test_apps/workbench_integration() {
cd "$WORKSPACE/apps/workbench" \
- && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec bin/rails test:integration TESTOPTS='-v -d' ${testargs[apps/workbench]} ${testargs[apps/workbench_integration]}
+ && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:integration TESTOPTS='-v -d' ${testargs[apps/workbench]} ${testargs[apps/workbench_integration]}
}
test_apps/workbench_benchmark() {
cd "$WORKSPACE/apps/workbench" \
- && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec bin/rails test:benchmark ${testargs[apps/workbench_benchmark]}
+ && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:benchmark ${testargs[apps/workbench_benchmark]}
}
test_apps/workbench_profile() {
cd "$WORKSPACE/apps/workbench" \
- && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec bin/rails test:profile ${testargs[apps/workbench_profile]}
+ && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:profile ${testargs[apps/workbench_profile]}
}
install_deps() {