Commit 48def9164bba6efbe79776d1026005c365534ae1
1 parent
91a6547c
Exists in
colab
and in
4 other branches
Started implementation of a form for Repository decoupled from Project
Signed-off-by: Daniel Miranda <danielkza2@gmail.com>
Showing
4 changed files
with
55 additions
and
3 deletions
Show diff stats
app/controllers/repositories_controller.rb
... | ... | @@ -30,8 +30,11 @@ class RepositoriesController < ApplicationController |
30 | 30 | # POST /projects/1/repositories |
31 | 31 | # POST /projects/1/repositories.json |
32 | 32 | def create |
33 | - @repository = Repository.new(repository_params) | |
34 | - @repository.project_id = params[:project_id] | |
33 | + r_params = repository_params | |
34 | + r_params.require(:project_id) | |
35 | + r_params[:project_id] = nil if r_params[:project_id].to_i == 0 | |
36 | + | |
37 | + @repository = Repository.new(r_params) | |
35 | 38 | respond_to do |format| |
36 | 39 | create_and_redir(format) |
37 | 40 | end |
... | ... | @@ -104,6 +107,9 @@ private |
104 | 107 | @configurations = KalibroConfiguration.public_or_owned_by_user(current_user).map { |conf| |
105 | 108 | [conf.name, conf.id] |
106 | 109 | } |
110 | + @projects = current_user.projects.map do |proj| | |
111 | + [proj.name, proj.id] | |
112 | + end if @project_id.nil? | |
107 | 113 | end |
108 | 114 | |
109 | 115 | # Duplicated code on create and update actions extracted here | ... | ... |
app/views/repositories/_form.html.erb
... | ... | @@ -102,6 +102,23 @@ |
102 | 102 | </div> |
103 | 103 | </div> |
104 | 104 | |
105 | + <div class="form-row"> | |
106 | + <div class="field-container"> | |
107 | + <%= f.label :project_id, Project.model_name.human, class: 'control-label' %> | |
108 | + <%= f.select( :project_id, @projects, class: 'tooltip-control' ) %> | |
109 | + | |
110 | + <div class="form-inline"> | |
111 | + <%= f.check_box :project_id, {id: "no_project_checkbox", class: "checkbox"}, "0", nil %> | |
112 | + <%= f.label "no_project" %> | |
113 | + </div> | |
114 | + </div> | |
115 | + <div class="help-container"> | |
116 | + <p> | |
117 | + <%= t('activemodel.hints.repository.project').html_safe %> | |
118 | + </p> | |
119 | + </div> | |
120 | + </div> | |
121 | + | |
105 | 122 | </div> |
106 | 123 | </div> |
107 | 124 | <div class="row margin-left-none" style="margin-top: 20px"> |
... | ... | @@ -114,5 +131,14 @@ |
114 | 131 | |
115 | 132 | $(document).on('page:load ready', function() { |
116 | 133 | _repository_branch.toggle(); |
134 | + | |
135 | + var checkbox = $("#no_project_checkbox"); | |
136 | + | |
137 | + function toggle() { | |
138 | + $("#repository_project_id").prop('disabled', checkbox.prop('checked')); | |
139 | + }; | |
140 | + | |
141 | + checkbox.on('click', toggle); | |
142 | + toggle(); | |
117 | 143 | }); |
118 | 144 | </script> | ... | ... |
features/repository/create.feature
... | ... | @@ -75,3 +75,19 @@ Scenario: Repository name with whitespaces |
75 | 75 | And I set the select field "Configuration" as "Java" |
76 | 76 | When I press the Save button |
77 | 77 | Then I should see "Name should be unique within project" |
78 | + | |
79 | +@kalibro_configuration_restart @kalibro_processor_restart @javascript | |
80 | +Scenario: Create repository without project | |
81 | + Given I am a regular user | |
82 | + And I am signed in | |
83 | + And I have a sample configuration with native metrics | |
84 | + And I am at the New Repository page | |
85 | + And I fill the Name field with "Kalibro Client" | |
86 | + And I set the select field "License" as "ISC License (ISC)" | |
87 | + And I fill the Address field with "https://github.com/mezuro/kalibro_client.git" | |
88 | + And I set the select field "Type" as "GIT" | |
89 | + And I set the select field "Process Period" as "1 day" | |
90 | + And I set the select field "Configuration" as "Java" | |
91 | + And I set the select field "Project" as "No Project" | |
92 | + When I press the Save button | |
93 | + Then I should see the saved repository's content | ... | ... |
features/step_definitions/repository_steps.rb
... | ... | @@ -66,7 +66,11 @@ Given(/^I wait up for a error processing$/) do |
66 | 66 | end |
67 | 67 | |
68 | 68 | Given(/^I am at the New Repository page$/) do |
69 | - visit new_project_repository_path(project_id: @project.id) | |
69 | + if @project | |
70 | + visit new_project_repository_path(project_id: @project.id) | |
71 | + else | |
72 | + visit new_repository_path | |
73 | + end | |
70 | 74 | end |
71 | 75 | |
72 | 76 | Given(/^I am at repository edit page$/) do | ... | ... |