Skip to content

Commit

Permalink
Fixes #4753 - Vendor url in installed package is the zammad instance …
Browse files Browse the repository at this point in the history
…url.

Co-authored-by: Florian Liebe <fl@zammad.com>
  • Loading branch information
rolfschmidt and fliebe92 committed Aug 25, 2023
1 parent 97b3d6a commit 8284610
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/assets/javascripts/app/views/package.jst.eco
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<tr data-id="<%= item.id %>">
<td><%= item.name %></td>
<td><%= item.version %></td>
<td><a href="<%- item.url %>" target="_blank"><%= item.vendor %></a></td>
<td><% if item.url: %><a href="<%= item.url %>" target="_blank"><% end %><%= item.vendor %><% if item.url: %></a><% end %></td>
<td><%- @T(item.state) %></td>
<td><% for action in item.action: %><a href="#" class="package-action btn btn--action<%= ' btn--danger' if action == 'uninstall' %>" data-type="<%= action %>"><%- @T(action) %></a><br/><% end %></td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def self.install(data)
name: package['name'],
version: package['version'],
vendor: package['vendor'],
url: package['url'],
state: 'uninstalled',
created_by_id: 1,
updated_by_id: 1,
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20120101000001_create_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def up
t.string :version, limit: 50, null: false
t.string :vendor, limit: 150, null: false
t.string :state, limit: 50, null: false
t.string :url, limit: 512, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps limit: 3, null: false
Expand Down
19 changes: 19 additions & 0 deletions db/migrate/20230825101042_show_package_url.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/

class ShowPackageUrl < ActiveRecord::Migration[6.1]
def change
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')

add_column :packages, :url, :string, limit: 512
Package.reset_column_information

Package.find_each do |package|
json_file = Package._get_bin(package.name, package.version)
data = JSON.parse(json_file)
next if data['url'].blank?

package.update!(url: data['url'])
end
end
end
7 changes: 7 additions & 0 deletions spec/models/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,11 @@ def expect_uninstall_package
expect_uninstall_package
end
end

describe 'Vendor url in installed package is the zammad instance url #4753' do
it 'does have a url for the package' do
described_class.install(string: package_zpm_json)
expect(described_class.last.url).to eq('https://zammad.org/')
end
end
end

0 comments on commit 8284610

Please sign in to comment.