Commit b7e10d2d1dc73bd19d8571f8f73a64b68916dfa6
Committed by
Diego Camarinha
1 parent
927d43cc
Exists in
colab
and in
4 other branches
Completed unit tests coverage
Also removed unused variables from repository controller spec Signed off by: Pedro Scocco <pedroscocco@gmail.com>
Showing
2 changed files
with
17 additions
and
8 deletions
Show diff stats
spec/controllers/metric_configurations_controller_spec.rb
| @@ -24,12 +24,16 @@ describe MetricConfigurationsController, :type => :controller do | @@ -24,12 +24,16 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 24 | describe 'new' do | 24 | describe 'new' do |
| 25 | let!(:metric_collector) { FactoryGirl.build(:metric_collector) } | 25 | let!(:metric_collector) { FactoryGirl.build(:metric_collector) } |
| 26 | let!(:native_metric) { FactoryGirl.build(:loc) } | 26 | let!(:native_metric) { FactoryGirl.build(:loc) } |
| 27 | + let!(:reading_groups) { [FactoryGirl.build(:reading_group)] } | ||
| 28 | + let!(:user) { FactoryGirl.create(:user) } | ||
| 29 | + | ||
| 27 | before :each do | 30 | before :each do |
| 28 | - sign_in FactoryGirl.create(:user) | 31 | + sign_in user |
| 29 | end | 32 | end |
| 30 | 33 | ||
| 31 | context 'when the current user owns the kalibro configuration' do | 34 | context 'when the current user owns the kalibro configuration' do |
| 32 | before :each do | 35 | before :each do |
| 36 | + ReadingGroup.expects(:public_or_owned_by_user).with(user).returns(reading_groups) | ||
| 33 | subject.expects(:kalibro_configuration_owner?).returns true | 37 | subject.expects(:kalibro_configuration_owner?).returns true |
| 34 | KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | 38 | KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) |
| 35 | metric_collector.expects(:find_metric_by_code).with(native_metric.code).returns(native_metric) | 39 | metric_collector.expects(:find_metric_by_code).with(native_metric.code).returns(native_metric) |
| @@ -108,14 +112,17 @@ describe MetricConfigurationsController, :type => :controller do | @@ -108,14 +112,17 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 108 | 112 | ||
| 109 | describe 'edit' do | 113 | describe 'edit' do |
| 110 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | 114 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } |
| 115 | + let!(:reading_groups) { [FactoryGirl.build(:reading_group)] } | ||
| 116 | + let!(:user) { FactoryGirl.create(:user) } | ||
| 111 | 117 | ||
| 112 | context 'with a User logged in' do | 118 | context 'with a User logged in' do |
| 113 | before do | 119 | before do |
| 114 | - sign_in FactoryGirl.create(:user) | 120 | + sign_in user |
| 115 | end | 121 | end |
| 116 | 122 | ||
| 117 | context 'when the user owns the metric configuration' do | 123 | context 'when the user owns the metric configuration' do |
| 118 | before :each do | 124 | before :each do |
| 125 | + ReadingGroup.expects(:public_or_owned_by_user).with(user).returns(reading_groups) | ||
| 119 | subject.expects(:metric_configuration_owner?).returns(true) | 126 | subject.expects(:metric_configuration_owner?).returns(true) |
| 120 | MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | 127 | MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) |
| 121 | get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s | 128 | get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
spec/controllers/repositories_controller_spec.rb
| @@ -5,12 +5,15 @@ describe RepositoriesController, :type => :controller do | @@ -5,12 +5,15 @@ describe RepositoriesController, :type => :controller do | ||
| 5 | 5 | ||
| 6 | describe 'new' do | 6 | describe 'new' do |
| 7 | context 'with a User logged in' do | 7 | context 'with a User logged in' do |
| 8 | + let!(:user) { FactoryGirl.create(:user) } | ||
| 9 | + let!(:kalibro_configurations) { [FactoryGirl.build(:kalibro_configuration)] } | ||
| 8 | before :each do | 10 | before :each do |
| 9 | - sign_in FactoryGirl.create(:user) | 11 | + sign_in user |
| 10 | end | 12 | end |
| 11 | 13 | ||
| 12 | context 'when the current user owns the project' do | 14 | context 'when the current user owns the project' do |
| 13 | before :each do | 15 | before :each do |
| 16 | + KalibroConfiguration.expects(:public_or_owned_by_user).with(user).returns(kalibro_configurations) | ||
| 14 | Repository.expects(:repository_types).returns([]) | 17 | Repository.expects(:repository_types).returns([]) |
| 15 | subject.expects(:project_owner?).returns true | 18 | subject.expects(:project_owner?).returns true |
| 16 | 19 | ||
| @@ -91,8 +94,6 @@ describe RepositoriesController, :type => :controller do | @@ -91,8 +94,6 @@ describe RepositoriesController, :type => :controller do | ||
| 91 | 94 | ||
| 92 | context 'without a specific module_result' do | 95 | context 'without a specific module_result' do |
| 93 | before :each do | 96 | before :each do |
| 94 | - processing = FactoryGirl.build(:processing) | ||
| 95 | - | ||
| 96 | KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) | 97 | KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) |
| 97 | Repository.expects(:find).with(repository.id).returns(repository) | 98 | Repository.expects(:find).with(repository.id).returns(repository) |
| 98 | 99 | ||
| @@ -105,8 +106,6 @@ describe RepositoriesController, :type => :controller do | @@ -105,8 +106,6 @@ describe RepositoriesController, :type => :controller do | ||
| 105 | context 'for an specific module_result' do | 106 | context 'for an specific module_result' do |
| 106 | 107 | ||
| 107 | before :each do | 108 | before :each do |
| 108 | - processing = FactoryGirl.build(:processing) | ||
| 109 | - | ||
| 110 | KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) | 109 | KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) |
| 111 | Repository.expects(:find).with(repository.id).returns(repository) | 110 | Repository.expects(:find).with(repository.id).returns(repository) |
| 112 | 111 | ||
| @@ -161,12 +160,15 @@ describe RepositoriesController, :type => :controller do | @@ -161,12 +160,15 @@ describe RepositoriesController, :type => :controller do | ||
| 161 | let(:repository) { FactoryGirl.build(:repository) } | 160 | let(:repository) { FactoryGirl.build(:repository) } |
| 162 | 161 | ||
| 163 | context 'with an User logged in' do | 162 | context 'with an User logged in' do |
| 163 | + let!(:user) { FactoryGirl.create(:user) } | ||
| 164 | + let!(:kalibro_configurations) { [FactoryGirl.build(:kalibro_configuration)] } | ||
| 164 | before do | 165 | before do |
| 165 | - sign_in FactoryGirl.create(:user) | 166 | + sign_in user |
| 166 | end | 167 | end |
| 167 | 168 | ||
| 168 | context 'when the user owns the repository' do | 169 | context 'when the user owns the repository' do |
| 169 | before :each do | 170 | before :each do |
| 171 | + KalibroConfiguration.expects(:public_or_owned_by_user).with(user).returns(kalibro_configurations) | ||
| 170 | subject.expects(:repository_owner?).returns true | 172 | subject.expects(:repository_owner?).returns true |
| 171 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | 173 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 172 | Repository.expects(:repository_types).returns(["SUBVERSION"]) | 174 | Repository.expects(:repository_types).returns(["SUBVERSION"]) |