Commit 3137a0c84815ade891a13bc2a5c23ecc548d4195
Committed by
Rafael Manzo
1 parent
5144eeaf
Exists in
colab
and in
4 other branches
Tests should pass now!
Showing
7 changed files
with
37 additions
and
42 deletions
Show diff stats
app/controllers/repositories_controller.rb
| ... | ... | @@ -108,7 +108,7 @@ private |
| 108 | 108 | end |
| 109 | 109 | |
| 110 | 110 | def set_configuration |
| 111 | - @configuration = KalibroGem::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! | |
| 111 | + @configuration = MezuroConfiguration.find(@repository.configuration_id) | |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | 114 | # Never trust parameters from the scary internet, only allow the white list through. | ... | ... |
features/step_definitions/repository_steps.rb
| ... | ... | @@ -2,7 +2,7 @@ Given(/^I have a sample configuration with native metrics$/) do |
| 2 | 2 | reading_group = FactoryGirl.create(:reading_group, id: nil) |
| 3 | 3 | reading = FactoryGirl.create(:reading, {id: nil, group_id: reading_group.id}) |
| 4 | 4 | range = FactoryGirl.build(:range, {id: nil, reading_id: reading.id, beginning: '-INF', :end => '+INF'}) |
| 5 | - @configuration = FactoryGirl.create(:configuration, id: nil) | |
| 5 | + @configuration = FactoryGirl.create(:mezuro_configuration, id: nil) | |
| 6 | 6 | metric_configuration = FactoryGirl.create(:metric_configuration, |
| 7 | 7 | {id: nil, |
| 8 | 8 | metric: FactoryGirl.build(:loc), | ... | ... |
spec/controllers/repositories_controller_spec.rb
| ... | ... | @@ -83,7 +83,7 @@ describe RepositoriesController do |
| 83 | 83 | before :each do |
| 84 | 84 | processing = FactoryGirl.build(:processing) |
| 85 | 85 | |
| 86 | - KalibroGem::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | |
| 86 | + MezuroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:mezuro_configuration)) | |
| 87 | 87 | Repository.expects(:find).with(repository.id).returns(repository) |
| 88 | 88 | |
| 89 | 89 | get :show, id: repository.id.to_s, project_id: project.id.to_s |
| ... | ... | @@ -97,7 +97,7 @@ describe RepositoriesController do |
| 97 | 97 | before :each do |
| 98 | 98 | processing = FactoryGirl.build(:processing) |
| 99 | 99 | |
| 100 | - KalibroGem::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | |
| 100 | + MezuroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:mezuro_configuration)) | |
| 101 | 101 | Repository.expects(:find).with(repository.id).returns(repository) |
| 102 | 102 | |
| 103 | 103 | get :show, id: repository.id.to_s, project_id: project.id.to_s |
| ... | ... | @@ -330,7 +330,7 @@ describe RepositoriesController do |
| 330 | 330 | subject.expects(:repository_owner?).returns true |
| 331 | 331 | repository.expects(:process) |
| 332 | 332 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 333 | - KalibroGem::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | |
| 333 | + MezuroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:mezuro_configuration)) | |
| 334 | 334 | get :process_repository, project_id: project.id.to_s, id: repository.id |
| 335 | 335 | end |
| 336 | 336 | it { should render_template(:show) } | ... | ... |
spec/models/configuration_spec.rb
| 1 | 1 | require 'spec_helper' |
| 2 | 2 | |
| 3 | -describe Configuration do | |
| 4 | - subject { FactoryGirl.build(:configuration) } | |
| 3 | +describe MezuroConfiguration do | |
| 4 | + subject { FactoryGirl.build(:mezuro_configuration) } | |
| 5 | 5 | describe 'methods' do |
| 6 | 6 | describe 'persisted?' do |
| 7 | 7 | before :each do |
| 8 | - Configuration.expects(:exists?).with(subject.id).returns(false) | |
| 8 | + MezuroConfiguration.expects(:exists?).with(subject.id).returns(false) | |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | 11 | it 'should return false' do |
| ... | ... | @@ -15,7 +15,7 @@ describe Configuration do |
| 15 | 15 | |
| 16 | 16 | describe 'update' do |
| 17 | 17 | before :each do |
| 18 | - @subject_params = Hash[FactoryGirl.attributes_for(:configuration).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers | |
| 18 | + @subject_params = Hash[FactoryGirl.attributes_for(:mezuro_configuration).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers | |
| 19 | 19 | end |
| 20 | 20 | |
| 21 | 21 | context 'with valid attributes' do |
| ... | ... | @@ -43,14 +43,14 @@ describe Configuration do |
| 43 | 43 | describe 'validations' do |
| 44 | 44 | context 'active model validations' do |
| 45 | 45 | before :each do |
| 46 | - Configuration.expects(:all).at_least_once.returns([]) | |
| 46 | + MezuroConfiguration.expects(:all).at_least_once.returns([]) | |
| 47 | 47 | end |
| 48 | 48 | it { should validate_presence_of(:name) } |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | context 'kalibro validations' do |
| 52 | 52 | before :each do |
| 53 | - Configuration.expects(:request).returns(42) | |
| 53 | + MezuroConfiguration.expects(:request).returns(42) | |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | 56 | it 'should validate uniqueness' do | ... | ... |
spec/models/mezuro_configuration_spec.rb
spec/routing/configuration_routing_spec.rb
| ... | ... | @@ -1,26 +0,0 @@ |
| 1 | -require "spec_helper" | |
| 2 | - | |
| 3 | -describe ConfigurationsController do | |
| 4 | - describe "routing" do | |
| 5 | - it { should route(:get, '/configurations/new'). | |
| 6 | - to(controller: :configurations, action: :new) } | |
| 7 | - | |
| 8 | - it { should route(:get, '/configurations'). | |
| 9 | - to(controller: :configurations, action: :index) } | |
| 10 | - | |
| 11 | - it { should route(:post, '/configurations'). | |
| 12 | - to(controller: :configurations, action: :create) } | |
| 13 | - | |
| 14 | - it { should route(:get, '/configurations/1'). | |
| 15 | - to(controller: :configurations, action: :show, id: "1") } | |
| 16 | - | |
| 17 | - it { should route(:get, '/configurations/1/edit'). | |
| 18 | - to(controller: :configurations, action: :edit, id: "1") } | |
| 19 | - | |
| 20 | - it { should route(:put, '/configurations/1'). | |
| 21 | - to(controller: :configurations, action: :update, id: "1") } | |
| 22 | - | |
| 23 | - it { should route(:delete, '/configurations/1'). | |
| 24 | - to(controller: :configurations, action: :destroy, id: "1") } | |
| 25 | - end | |
| 26 | -end | |
| 27 | 0 | \ No newline at end of file |
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +require "spec_helper" | |
| 2 | + | |
| 3 | +describe MezuroConfigurationsController do | |
| 4 | + describe "routing" do | |
| 5 | + it { should route(:get, '/mezuro_configurations/new'). | |
| 6 | + to(controller: :mezuro_configurations, action: :new) } | |
| 7 | + | |
| 8 | + it { should route(:get, '/mezuro_configurations'). | |
| 9 | + to(controller: :mezuro_configurations, action: :index) } | |
| 10 | + | |
| 11 | + it { should route(:post, '/mezuro_configurations'). | |
| 12 | + to(controller: :mezuro_configurations, action: :create) } | |
| 13 | + | |
| 14 | + it { should route(:get, '/mezuro_configurations/1'). | |
| 15 | + to(controller: :mezuro_configurations, action: :show, id: "1") } | |
| 16 | + | |
| 17 | + it { should route(:get, '/mezuro_configurations/1/edit'). | |
| 18 | + to(controller: :mezuro_configurations, action: :edit, id: "1") } | |
| 19 | + | |
| 20 | + it { should route(:put, '/mezuro_configurations/1'). | |
| 21 | + to(controller: :mezuro_configurations, action: :update, id: "1") } | |
| 22 | + | |
| 23 | + it { should route(:delete, '/mezuro_configurations/1'). | |
| 24 | + to(controller: :mezuro_configurations, action: :destroy, id: "1") } | |
| 25 | + end | |
| 26 | +end | |
| 0 | 27 | \ No newline at end of file | ... | ... |