#192: updated cancan_spec, added tokens to urls of repositories for build_list

This commit is contained in:
Vokhmin Alexey V 2013-06-26 13:53:37 +04:00
parent 874086e1ca
commit 03a1fe1ba8
2 changed files with 15 additions and 7 deletions

View File

@ -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 = []

View File

@ -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