Skip to content

Commit

Permalink
[webui] Fix disabling of checkboxes on add_repository_from_default_li…
Browse files Browse the repository at this point in the history
…st page
  • Loading branch information
bgeuken committed Nov 22, 2015
1 parent d8cee2a commit d9999a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/api/app/models/project.rb
Expand Up @@ -162,7 +162,9 @@ def maintained_project_names
def has_distribution(project_name, repository)
project = Project.find_by(name: project_name)
return false unless project
repositories.joins(path_elements: :link).where(links_path_elements: {name: repository, db_project_id: project.id }).exists?

link_id = project.repositories.find_by(name: repository).try(:id)
repositories.joins(path_elements: :link).where(links_path_elements: { id: link_id }).exists?
end

def number_of_build_problems
Expand Down
Expand Up @@ -16,7 +16,7 @@
<h3><%= sprite_tag("distributions-#{vendor.downcase}") %> <%= vendor -%> distributions</h3>
<p>
<% list.each do |distribution| %>
<% selected = @project.has_distribution(distribution['project'], distribution['repo']) %>
<% selected = @project.has_distribution(distribution['project'], distribution['repository']) %>
<span class="nowrap">
<%= check_box_tag 'distributions[]', distribution['reponame'], selected, :disabled => selected, :id => 'repo_' + distribution['reponame'], :class => 'repocheckbox' -%>
<label for="<%= "repo_#{distribution['reponame']}" %>"><%= distribution['name'] %></label>
Expand Down
5 changes: 5 additions & 0 deletions src/api/test/functional/webui/project_controller_test.rb
Expand Up @@ -24,6 +24,11 @@ def test_save_distributions
find("#submitrepos").click
page.must_have_text "Successfully added repositories"
assert_equal "/project/repositories/home:tom", page.current_path

# Test that repository checkbox get's disabled
visit "/project/add_repository_from_default_list/home:tom"
assert find("input#repo_Base_repo").disabled?,
"Checkbox for 'OBS Base 2.0' should be disabled"
end

def test_save_distributions_with_existing_repository
Expand Down

0 comments on commit d9999a5

Please sign in to comment.