diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 7ab46c41c..2d4a39d1a 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -396,20 +396,20 @@ class BuildList < ActiveRecord::Base repos = include_repos include_repos_hash = {}.tap do |h| Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo| - path = repo.platform.public_downloads_url( + path, prefix = repo.platform.public_downloads_url( repo.platform.main? ? nil : build_for_platform.name, arch.name, repo.name - ) - h["#{repo.platform.name}_#{repo.name}_release"] = path + 'release' - h["#{repo.platform.name}_#{repo.name}_updates"] = path + 'updates' if repo.platform.main? + ), "#{repo.platform.name}_#{repo.name}_" + h["#{prefix}release"] = insert_token_to_path(path + 'release', repo.platform) + h["#{prefix}updates"] = insert_token_to_path(path + 'updates', repo.platform) if repo.platform.main? end end host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host] BuildList.where(:id => extra_build_lists).each do |bl| path = "#{APP_CONFIG['downloads_url']}/#{bl.save_to_platform.name}/container/" path << "#{bl.id}/#{bl.arch.name}/#{bl.save_to_repository.name}/release" - include_repos_hash["container_#{bl.id}"] = path + include_repos_hash["container_#{bl.id}"] = insert_token_to_path(path, bl.save_to_platform) end git_project_address = project.git_project_address user @@ -427,6 +427,14 @@ class BuildList < ActiveRecord::Base } end + def insert_token_to_path(path, platform) + if platform.hidden? + path.gsub(/^http:\/\//, "http://#{user.authentication_token}:@") + else + path + end + end + def notify_users unless mass_build_id users = [] diff --git a/spec/models/cancan_spec.rb b/spec/models/cancan_spec.rb index 0a0230107..bf79241ad 100644 --- a/spec/models/cancan_spec.rb +++ b/spec/models/cancan_spec.rb @@ -241,7 +241,7 @@ describe CanCan do @platform.save end - [:read, :update, :destroy].each do |action| + [:read, :update, :destroy, :change_visibility].each do |action| it "should be able to #{action} platform" do @ability.should be_able_to(action, @platform) end @@ -270,7 +270,7 @@ describe CanCan do @repository.platform.save end - [:read, :create, :update, :destroy, :add_project, :remove_project, :change_visibility, :settings].each do |action| + [:read, :create, :update, :destroy, :add_project, :remove_project, :settings].each do |action| it "should be able to #{action} repository" do @ability.should be_able_to(action, @repository) end