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 | 24 | describe 'new' do |
25 | 25 | let!(:metric_collector) { FactoryGirl.build(:metric_collector) } |
26 | 26 | let!(:native_metric) { FactoryGirl.build(:loc) } |
27 | + let!(:reading_groups) { [FactoryGirl.build(:reading_group)] } | |
28 | + let!(:user) { FactoryGirl.create(:user) } | |
29 | + | |
27 | 30 | before :each do |
28 | - sign_in FactoryGirl.create(:user) | |
31 | + sign_in user | |
29 | 32 | end |
30 | 33 | |
31 | 34 | context 'when the current user owns the kalibro configuration' do |
32 | 35 | before :each do |
36 | + ReadingGroup.expects(:public_or_owned_by_user).with(user).returns(reading_groups) | |
33 | 37 | subject.expects(:kalibro_configuration_owner?).returns true |
34 | 38 | KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) |
35 | 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 | 112 | |
109 | 113 | describe 'edit' do |
110 | 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 | 118 | context 'with a User logged in' do |
113 | 119 | before do |
114 | - sign_in FactoryGirl.create(:user) | |
120 | + sign_in user | |
115 | 121 | end |
116 | 122 | |
117 | 123 | context 'when the user owns the metric configuration' do |
118 | 124 | before :each do |
125 | + ReadingGroup.expects(:public_or_owned_by_user).with(user).returns(reading_groups) | |
119 | 126 | subject.expects(:metric_configuration_owner?).returns(true) |
120 | 127 | MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) |
121 | 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 | 5 | |
6 | 6 | describe 'new' do |
7 | 7 | context 'with a User logged in' do |
8 | + let!(:user) { FactoryGirl.create(:user) } | |
9 | + let!(:kalibro_configurations) { [FactoryGirl.build(:kalibro_configuration)] } | |
8 | 10 | before :each do |
9 | - sign_in FactoryGirl.create(:user) | |
11 | + sign_in user | |
10 | 12 | end |
11 | 13 | |
12 | 14 | context 'when the current user owns the project' do |
13 | 15 | before :each do |
16 | + KalibroConfiguration.expects(:public_or_owned_by_user).with(user).returns(kalibro_configurations) | |
14 | 17 | Repository.expects(:repository_types).returns([]) |
15 | 18 | subject.expects(:project_owner?).returns true |
16 | 19 | |
... | ... | @@ -91,8 +94,6 @@ describe RepositoriesController, :type => :controller do |
91 | 94 | |
92 | 95 | context 'without a specific module_result' do |
93 | 96 | before :each do |
94 | - processing = FactoryGirl.build(:processing) | |
95 | - | |
96 | 97 | KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) |
97 | 98 | Repository.expects(:find).with(repository.id).returns(repository) |
98 | 99 | |
... | ... | @@ -105,8 +106,6 @@ describe RepositoriesController, :type => :controller do |
105 | 106 | context 'for an specific module_result' do |
106 | 107 | |
107 | 108 | before :each do |
108 | - processing = FactoryGirl.build(:processing) | |
109 | - | |
110 | 109 | KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) |
111 | 110 | Repository.expects(:find).with(repository.id).returns(repository) |
112 | 111 | |
... | ... | @@ -161,12 +160,15 @@ describe RepositoriesController, :type => :controller do |
161 | 160 | let(:repository) { FactoryGirl.build(:repository) } |
162 | 161 | |
163 | 162 | context 'with an User logged in' do |
163 | + let!(:user) { FactoryGirl.create(:user) } | |
164 | + let!(:kalibro_configurations) { [FactoryGirl.build(:kalibro_configuration)] } | |
164 | 165 | before do |
165 | - sign_in FactoryGirl.create(:user) | |
166 | + sign_in user | |
166 | 167 | end |
167 | 168 | |
168 | 169 | context 'when the user owns the repository' do |
169 | 170 | before :each do |
171 | + KalibroConfiguration.expects(:public_or_owned_by_user).with(user).returns(kalibro_configurations) | |
170 | 172 | subject.expects(:repository_owner?).returns true |
171 | 173 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
172 | 174 | Repository.expects(:repository_types).returns(["SUBVERSION"]) | ... | ... |