-
- <%= f.label :branch, class: 'control-label' %>
- <%= f.text_field :branch, class: 'text-field form-control' %>
-
-
-
- <%= t('activemodel.hints.repository.branch') %>
-
+
@@ -106,3 +108,43 @@
<%= f.submit t('save'), class: 'btn btn-primary' %>
<%= link_to t('back'), project_path(@project_id), class: 'btn btn-default' %>
+
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index c1ffb4f..2c5513c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,6 +12,8 @@ Rails.application.routes.draw do
get '/repositories/:id/process' => 'repositories#process_repository', as: :repository_process
end
+ get '/repository_branches' => 'repositories#branches', as: :repository_branches
+
resources :kalibro_configurations do
get '/metric_configurations/choose_metric' => 'metric_configurations#choose_metric', as: :choose_metric
resources :metric_configurations, except: [:update, :new] do
diff --git a/features/repository/create.feature b/features/repository/create.feature
index edcebcc..d79fff7 100644
--- a/features/repository/create.feature
+++ b/features/repository/create.feature
@@ -3,7 +3,7 @@ Feature: Repository Creation
As a regular user
I should be able to create repositories
-@kalibro_configuration_restart @kalibro_processor_restart @javascript
+@kalibro_configuration_restart @kalibro_processor_restart @javascript @wip
Scenario: repository creation
Given I am a regular user
And I am signed in
@@ -13,14 +13,14 @@ Scenario: repository creation
And I fill the Name field with "Kalibro"
And I fill the Description field with "Description"
And I set the select field "License" as "ISC License (ISC)"
+ And I fill the Address field with "https://github.com/mezuro/kalibro_client.git"
And I set the select field "Type" as "GIT"
- And I fill the Address field with "https://github.com/mezuro/kalibro_gem.git"
And I set the select field "Process Period" as "1 day"
And I set the select field "Configuration" as "Java"
When I press the Save button
Then I should see the saved repository's content
-@kalibro_configuration_restart @kalibro_processor_restart @javascript
+@kalibro_configuration_restart @kalibro_processor_restart @javascript @wip
Scenario: repository creation blank validations
Given I am a regular user
And I am signed in
@@ -37,7 +37,7 @@ Scenario: repository creation blank validations
Then I should see "Name can't be blank"
And I should see "Address can't be blank"
-@kalibro_configuration_restart @kalibro_processor_restart @javascript
+@kalibro_configuration_restart @kalibro_processor_restart @javascript @wip
Scenario: repository creation with name already taken
Given I am a regular user
And I am signed in
@@ -48,14 +48,14 @@ Scenario: repository creation with name already taken
And I fill the Name field with "KalibroEntities"
And I fill the Description field with "Description"
And I set the select field "License" as "ISC License (ISC)"
+ And I fill the Address field with "https://github.com/mezuro/kalibro_client.git"
And I set the select field "Type" as "GIT"
- And I fill the Address field with "https://github.com/mezuro/kalibro_gem.git"
And I set the select field "Process Period" as "1 day"
And I set the select field "Configuration" as "Java"
When I press the Save button
Then I should see "Name should be unique within project"
-@kalibro_configuration_restart @kalibro_processor_restart @javascript
+@kalibro_configuration_restart @kalibro_processor_restart @javascript @wip
Scenario: Repository name with whitespaces
Given I am a regular user
And I am signed in
@@ -65,8 +65,8 @@ Scenario: Repository name with whitespaces
And I am at the New Repository page
And I fill the Name field with " Kalibro Entities "
And I set the select field "License" as "ISC License (ISC)"
+ And I fill the Address field with "https://github.com/mezuro/kalibro_client.git"
And I set the select field "Type" as "GIT"
- And I fill the Address field with "https://github.com/mezuro/kalibro_gem.git"
And I set the select field "Process Period" as "1 day"
And I set the select field "Configuration" as "Java"
When I press the Save button
diff --git a/features/repository/show/date_select.feature b/features/repository/show/date_select.feature
index 55c7a63..36e115e 100644
--- a/features/repository/show/date_select.feature
+++ b/features/repository/show/date_select.feature
@@ -3,7 +3,7 @@ Feature: Date Select
As a regular user
I should be able to select a specific date
- @kalibro_configuration_restart @kalibro_processor_restart @javascript
+ @kalibro_configuration_restart @kalibro_processor_restart @javascript @wip
Scenario: With a specific date selected
Given I have a sample project
And I have a sample configuration with native metrics
diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb
index 7b2a0bb..810dbd4 100644
--- a/spec/controllers/repositories_controller_spec.rb
+++ b/spec/controllers/repositories_controller_spec.rb
@@ -347,4 +347,39 @@ describe RepositoriesController, :type => :controller do
end
it { is_expected.to redirect_to(project_repository_path(repository.project_id, repository.id)) }
end
+
+ describe 'branches' do
+ let(:url) { "dummy-url" }
+ let(:scm_type) { "GIT" }
+
+ context 'valid parameters' do
+ let!(:branches) { ['branch1', 'branch2'] }
+
+ before :each do
+ sign_in FactoryGirl.create(:user)
+ Repository.expects(:branches).with(url, scm_type).returns(branches: branches)
+ get :branches, url: url, scm_type: scm_type, format: :json
+ end
+
+ it 'is expected to return a list of branches' do
+ expect(JSON.parse(response.body)).to eq(JSON.parse({branches: branches}.to_json))
+ end
+
+ it { is_expected.to respond_with(:success) }
+ end
+
+ context 'invalid parameters' do
+ before :each do
+ sign_in FactoryGirl.create(:user)
+ Repository.expects(:branches).with(url, scm_type).returns(errors: ['Error'])
+ get :branches, url: url, scm_type: scm_type, format: :json
+ end
+
+ it 'is expected to return an empty list' do
+ expect(JSON.parse(response.body)).to eq(JSON.parse({errors: ['Error']}.to_json))
+ end
+
+ it { is_expected.to respond_with(:success) }
+ end
+ end
end
diff --git a/spec/routing/repositories_routing_spec.rb b/spec/routing/repositories_routing_spec.rb
index 006f072..25cf171 100644
--- a/spec/routing/repositories_routing_spec.rb
+++ b/spec/routing/repositories_routing_spec.rb
@@ -24,5 +24,7 @@ describe RepositoriesController, :type => :routing do
to(controller: :repositories, action: :state_with_date, project_id: 1, id: 1) }
it { is_expected.to route(:get, '/projects/1/repositories/1/process').
to(controller: :repositories, action: :process_repository, project_id: 1, id: 1) }
+ it { is_expected.to route(:get, '/repository_branches').
+ to(controller: :repositories, action: :branches) }
end
end
--
libgit2 0.21.2