Commit 60ff8362b484f937529b39f3a272a99817ba8965
Committed by
Alessandro Palmeira
Exists in
master
and in
28 other branches
Merge branch 'refactoring_repository' into refactoring
Conflicts: plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb plugins/mezuro/lib/kalibro/configuration.rb plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
Showing
11 changed files
with
164 additions
and
65 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
| ... | ... | @@ -37,7 +37,8 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController |
| 37 | 37 | @configuration_select = configurations.map do |configuration| |
| 38 | 38 | [configuration.name,configuration.id] |
| 39 | 39 | end |
| 40 | - @repository = @project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first | |
| 40 | + | |
| 41 | + @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first | |
| 41 | 42 | end |
| 42 | 43 | |
| 43 | 44 | def update |
| ... | ... | @@ -57,7 +58,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController |
| 57 | 58 | project_content = profile.articles.find(params[:id]) |
| 58 | 59 | @project_name = project_content.name |
| 59 | 60 | @repository = project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first |
| 60 | - @configuration_name = Kalibro::Configuration.find(@repository.configuration_id).name | |
| 61 | + @configuration_name = Kalibro::Configuration.configuration_of(@repository.id).name | |
| 61 | 62 | @processing = processing(@repository.id) |
| 62 | 63 | end |
| 63 | 64 | |
| ... | ... | @@ -68,39 +69,12 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController |
| 68 | 69 | if( repository.errors.empty? ) |
| 69 | 70 | redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" |
| 70 | 71 | else |
| 71 | - raise repository.errors[0].message | |
| 72 | 72 | redirect_to_error_page repository.errors[0].message |
| 73 | 73 | end |
| 74 | 74 | end |
| 75 | 75 | |
| 76 | 76 | private |
| 77 | 77 | |
| 78 | - def processing(repository_id) | |
| 79 | - begin | |
| 80 | - if Kalibro::Processing.has_ready_processing(repository_id) | |
| 81 | - @processing ||= Kalibro::Processing.last_ready_processing_of(repository_id) | |
| 82 | - else | |
| 83 | - @processing = Kalibro::Processing.last_processing_of(repository_id) | |
| 84 | - end | |
| 85 | - rescue Exception => error | |
| 86 | - errors.add_to_base(error.message) | |
| 87 | - end | |
| 88 | - @processing | |
| 89 | - end | |
| 90 | - | |
| 91 | - def processing_with_date(repository_id, date) | |
| 92 | - begin | |
| 93 | - if Kalibro::Processing.has_processing_after(repository_id, date) | |
| 94 | - @processing ||= Kalibro::Processing.first_processing_after(repository_id, date) | |
| 95 | - elsif Kalibro::Processing.has_processing_before(repository_id, date) | |
| 96 | - @processing ||= Kalibro::Processing.last_processing_before(repository_id, date) | |
| 97 | - end | |
| 98 | - rescue Exception => error | |
| 99 | - errors.add_to_base(error.message) | |
| 100 | - end | |
| 101 | - @processing | |
| 102 | - end | |
| 103 | - | |
| 104 | 78 | def module_result(repository_id, date = nil) |
| 105 | 79 | @processing ||= date.nil? ? processing(repository_id) : processing_with_date(repository_id, date) |
| 106 | 80 | begin | ... | ... |
plugins/mezuro/lib/kalibro/configuration.rb
| ... | ... | @@ -9,7 +9,7 @@ class Kalibro::Configuration < Kalibro::Model |
| 9 | 9 | def self.all |
| 10 | 10 | response = request(:all_configurations)[:configuration] |
| 11 | 11 | response = [] if response.nil? |
| 12 | - response = [response] if response.is_a? (Hash) | |
| 12 | + response = [response] if response.is_a?(Hash) | |
| 13 | 13 | response.map {|configuration| new configuration} |
| 14 | 14 | end |
| 15 | 15 | ... | ... |
plugins/mezuro/lib/kalibro/processing.rb
| ... | ... | @@ -2,6 +2,42 @@ class Kalibro::Processing < Kalibro::Model |
| 2 | 2 | |
| 3 | 3 | attr_accessor :id, :date, :state, :error, :process_time, :results_root_id |
| 4 | 4 | |
| 5 | + def self.processing_of(repository_id) | |
| 6 | + if has_ready_processing(repository_id) | |
| 7 | + last_ready_processing_of(repository_id) | |
| 8 | + else | |
| 9 | + last_processing_of(repository_id) | |
| 10 | + end | |
| 11 | + end | |
| 12 | + | |
| 13 | + def self.processing_with_date_of(repository_id, date) | |
| 14 | + if has_processing_after(repository_id, date) | |
| 15 | + first_processing_after(repository_id, date) | |
| 16 | + elsif has_processing_before(repository_id, date) | |
| 17 | + last_processing_before(repository_id, date) | |
| 18 | + else | |
| 19 | + last_processing_of(repository_id) | |
| 20 | + end | |
| 21 | + end | |
| 22 | + | |
| 23 | + def date=(value) | |
| 24 | + @date = value.is_a?(String) ? DateTime.parse(value) : value | |
| 25 | + end | |
| 26 | + | |
| 27 | + def process_times=(value) | |
| 28 | + process_time=value | |
| 29 | + end | |
| 30 | + | |
| 31 | + def process_time=(value) | |
| 32 | + @process_time = Kalibro::ProcessTime.to_objects_array value | |
| 33 | + end | |
| 34 | + | |
| 35 | + def process_times | |
| 36 | + process_time | |
| 37 | + end | |
| 38 | + | |
| 39 | + private | |
| 40 | + | |
| 5 | 41 | def self.has_processing(repository_id) |
| 6 | 42 | request(:has_processing, {:repository_id => repository_id})[:exists] |
| 7 | 43 | end |
| ... | ... | @@ -42,20 +78,4 @@ class Kalibro::Processing < Kalibro::Model |
| 42 | 78 | new request(:last_processing_before, {:repository_id => repository_id, :date => date})[:processing] |
| 43 | 79 | end |
| 44 | 80 | |
| 45 | - def date=(value) | |
| 46 | - @date = value.is_a?(String) ? DateTime.parse(value) : value | |
| 47 | - end | |
| 48 | - | |
| 49 | - def process_times=(value) | |
| 50 | - process_time=value | |
| 51 | - end | |
| 52 | - | |
| 53 | - def process_time=(value) | |
| 54 | - @process_time = Kalibro::ProcessTime.to_objects_array value | |
| 55 | - end | |
| 56 | - | |
| 57 | - def process_times | |
| 58 | - process_time | |
| 59 | - end | |
| 60 | - | |
| 61 | 81 | end | ... | ... |
plugins/mezuro/test/fixtures/configuration_fixtures.rb
plugins/mezuro/test/fixtures/repository_fixtures.rb
| ... | ... | @@ -20,4 +20,8 @@ class RepositoryFixtures |
| 20 | 20 | {:id => 42, :name => "test repository", :description => "test description", :license => "GPL", :process_period => "1", :type => 'SUBVERSION', :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator', :configuration_id => 31} |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | + def self.types | |
| 24 | + ["SUBVERSION", "GIT"] | |
| 25 | + end | |
| 26 | + | |
| 23 | 27 | end | ... | ... |
plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb
| 1 | 1 | require 'test_helper' |
| 2 | 2 | |
| 3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | |
| 4 | 3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" |
| 5 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures" | |
| 4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_fixtures" | |
| 6 | 5 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" |
| 7 | 6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" |
| 8 | 7 | |
| ... | ... | @@ -16,7 +15,7 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase |
| 16 | 15 | |
| 17 | 16 | @base_tool = BaseToolFixtures.base_tool |
| 18 | 17 | @base_tool_hash = BaseToolFixtures.base_tool_hash |
| 19 | - @metric = NativeMetricFixtures.amloc | |
| 18 | + @metric = MetricFixtures.amloc | |
| 20 | 19 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration |
| 21 | 20 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash |
| 22 | 21 | @compound_metric_configuration = MetricConfigurationFixtures.sc_metric_configuration | ... | ... |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_metric_configuration_controller_test.rb
| 1 | 1 | require 'test_helper' |
| 2 | 2 | |
| 3 | 3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" |
| 4 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures" | |
| 4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_fixtures" | |
| 5 | 5 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" |
| 6 | 6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" |
| 7 | 7 | |
| ... | ... | @@ -15,7 +15,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
| 15 | 15 | |
| 16 | 16 | @base_tool = BaseToolFixtures.base_tool |
| 17 | 17 | @base_tool_hash = BaseToolFixtures.base_tool_hash |
| 18 | - @metric = NativeMetricFixtures.amloc | |
| 18 | + @metric = MetricFixtures.amloc | |
| 19 | 19 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration |
| 20 | 20 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash |
| 21 | 21 | @compound_metric_configuration = MetricConfigurationFixtures.sc_metric_configuration | ... | ... |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb
| 1 | 1 | require 'test_helper' |
| 2 | 2 | |
| 3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures" | |
| 3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_fixtures" | |
| 4 | 4 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" |
| 5 | 5 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" |
| 6 | 6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/range_fixtures" |
| ... | ... | @@ -13,7 +13,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase |
| 13 | 13 | @response = ActionController::TestResponse.new |
| 14 | 14 | @profile = fast_create(Community) |
| 15 | 15 | |
| 16 | - @metric = NativeMetricFixtures.amloc | |
| 16 | + @metric = MetricFixtures.amloc | |
| 17 | 17 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration |
| 18 | 18 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash |
| 19 | 19 | @configuration = ConfigurationFixtures.configuration | ... | ... |
plugins/mezuro/test/functional/profile/mezuro_plugin_project_controller_test.rb
| 1 | 1 | require 'test_helper' |
| 2 | 2 | |
| 3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" | |
| 4 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | |
| 3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures" | |
| 4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures" | |
| 5 | 5 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" |
| 6 | 6 | |
| 7 | 7 | class MezuroPluginProjectControllerTest < ActionController::TestCase |
| ... | ... | @@ -11,7 +11,7 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase |
| 11 | 11 | @response = ActionController::TestResponse.new |
| 12 | 12 | @profile = fast_create(Community) |
| 13 | 13 | |
| 14 | - @project_result = ProjectResultFixtures.project_result | |
| 14 | + @project_result = ProcessingFixtures.project_result | |
| 15 | 15 | @repository_url = RepositoryFixtures.repository.address |
| 16 | 16 | @project = @project_result.project |
| 17 | 17 | @date = "2012-04-13T20:39:41+04:00" |
| ... | ... | @@ -30,7 +30,7 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | should 'test project state with kalibro_error' do |
| 33 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
| 33 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})}) | |
| 34 | 34 | get :project_state, :profile => @profile.identifier, :id => @content.id |
| 35 | 35 | assert_response 200 |
| 36 | 36 | assert_equal "ERROR", @response.body |
| ... | ... | @@ -38,7 +38,7 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase |
| 38 | 38 | end |
| 39 | 39 | |
| 40 | 40 | should 'test project error' do |
| 41 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
| 41 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})}) | |
| 42 | 42 | get :project_error, :profile => @profile.identifier, :id => @content.id |
| 43 | 43 | assert_response 200 |
| 44 | 44 | assert_select('h3', 'ERROR') |
| ... | ... | @@ -47,7 +47,7 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase |
| 47 | 47 | end |
| 48 | 48 | |
| 49 | 49 | should 'test project result without date' do |
| 50 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
| 50 | + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
| 51 | 51 | get :project_result, :profile => @profile.identifier, :id => @content.id, :date => nil |
| 52 | 52 | assert_equal @content, assigns(:content) |
| 53 | 53 | assert_equal @project_result.project.name, assigns(:project_result).project.name |
| ... | ... | @@ -57,8 +57,8 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase |
| 57 | 57 | |
| 58 | 58 | should 'test project results from a specific date' do |
| 59 | 59 | request_body = {:project_name => @project.name, :date => @date} |
| 60 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
| 61 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
| 60 | + Kalibro::Processing.expects(:request).with("Processing", :has_results_before, request_body).returns({:has_results => true}) | |
| 61 | + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
| 62 | 62 | get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @date |
| 63 | 63 | assert_equal @content, assigns(:content) |
| 64 | 64 | assert_equal @project_result.project.name, assigns(:project_result).project.name |
| ... | ... | @@ -67,7 +67,7 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase |
| 67 | 67 | end |
| 68 | 68 | |
| 69 | 69 | should 'test project tree without date' do |
| 70 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
| 70 | + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
| 71 | 71 | Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) |
| 72 | 72 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil |
| 73 | 73 | assert_equal @content, assigns(:content) |
| ... | ... | @@ -80,8 +80,8 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase |
| 80 | 80 | should 'test project tree with a specific date' do |
| 81 | 81 | request_body = {:project_name => @project.name, :date => @project_result.date} |
| 82 | 82 | Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) |
| 83 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
| 84 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
| 83 | + Kalibro::Processing.expects(:request).with("Processing", :has_results_before, request_body).returns({:has_results => true}) | |
| 84 | + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
| 85 | 85 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date |
| 86 | 86 | assert_equal @content, assigns(:content) |
| 87 | 87 | assert_equal @project.name, assigns(:project_name) | ... | ... |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,99 @@ |
| 1 | +require 'test_helper' | |
| 2 | + | |
| 3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures" | |
| 4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures" | |
| 5 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | |
| 6 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_content_fixtures" | |
| 7 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" | |
| 8 | + | |
| 9 | +class MezuroPluginRepositoryControllerTest < ActionController::TestCase | |
| 10 | + | |
| 11 | + def setup | |
| 12 | + @controller = MezuroPluginRepositoryController.new | |
| 13 | + @request = ActionController::TestRequest.new | |
| 14 | + @response = ActionController::TestResponse.new | |
| 15 | + @profile = fast_create(Community) | |
| 16 | + | |
| 17 | + @configuration = ConfigurationFixtures.configuration | |
| 18 | + @repository_types = RepositoryFixtures.types | |
| 19 | + @all_configurations = ConfigurationFixtures.all | |
| 20 | + @repository = RepositoryFixtures.repository | |
| 21 | + @repository_hash = RepositoryFixtures.hash | |
| 22 | + @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => name) | |
| 23 | + @content.expects(:send_project_to_service).returns(nil) | |
| 24 | + @content.stubs(:solr_save) | |
| 25 | + @content.save | |
| 26 | + end | |
| 27 | + | |
| 28 | + should 'set variables to create a new repository' do | |
| 29 | + Kalibro::Repository.expects(:repository_types).returns(@repository_types) | |
| 30 | + Kalibro::Configuration.expects(:all).returns(@all_configurations) | |
| 31 | + | |
| 32 | + get :new, :profile => @profile.identifier, :id => @content.id | |
| 33 | + | |
| 34 | + assert_equal @content, assigns(:project_content) | |
| 35 | + assert_equal @repository_types, assigns(:repository_types) | |
| 36 | + assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first | |
| 37 | + assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last | |
| 38 | + end | |
| 39 | + | |
| 40 | + should 'create a repository' do | |
| 41 | + Kalibro::Repository.expects(:new).returns(@repository) | |
| 42 | + @repository.expects(:save).with(@content.project_id).returns(true) | |
| 43 | + get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
| 44 | + assert @repository.errors.empty? | |
| 45 | + assert_response :redirect | |
| 46 | + end | |
| 47 | + | |
| 48 | + should 'not create a repository' do | |
| 49 | + @repository.errors = [Exception.new] | |
| 50 | + Kalibro::Repository.expects(:new).returns(@repository) | |
| 51 | + @repository.expects(:save).with(@content.project_id).returns(false) | |
| 52 | + get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
| 53 | + assert !@repository.errors.empty? | |
| 54 | + assert_response :redirect | |
| 55 | + end | |
| 56 | + | |
| 57 | + should 'set variables to edit a repository' do | |
| 58 | + articles = mock | |
| 59 | + Kalibro::Repository.expects(:repository_types).returns(@repository_types) | |
| 60 | + Kalibro::Configuration.expects(:all).returns(@all_configurations) | |
| 61 | + Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository]) | |
| 62 | + | |
| 63 | + get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id | |
| 64 | + | |
| 65 | + assert_equal @content, assigns(:project_content) | |
| 66 | + assert_equal @repository_types, assigns(:repository_types) | |
| 67 | + assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first | |
| 68 | + assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last | |
| 69 | + assert_equal @repository, assigns(:repository) | |
| 70 | + end | |
| 71 | + | |
| 72 | + should 'update a repository' do | |
| 73 | + Kalibro::Repository.expects(:new).returns(@repository) | |
| 74 | + @repository.expects(:save).with(@content.project_id).returns(true) | |
| 75 | + get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
| 76 | + assert @repository.errors.empty? | |
| 77 | + assert_response :redirect | |
| 78 | + end | |
| 79 | + | |
| 80 | + should 'not update a repository' do | |
| 81 | + @repository.errors = [Exception.new] | |
| 82 | + Kalibro::Repository.expects(:new).returns(@repository) | |
| 83 | + @repository.expects(:save).with(@content.project_id).returns(false) | |
| 84 | + get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
| 85 | + assert !@repository.errors.empty? | |
| 86 | + assert_response :redirect | |
| 87 | + end | |
| 88 | + | |
| 89 | + should 'show a repository' do | |
| 90 | + Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository]) | |
| 91 | + Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) | |
| 92 | + | |
| 93 | + assert_equal @content.name, assigns(:project_name) | |
| 94 | + assert_equal @repository, assigns(:repository) | |
| 95 | + @configuration_name = Kalibro::Configuration.find(@repository.configuration_id).name | |
| 96 | + @processing = processing(@repository.id) | |
| 97 | + end | |
| 98 | + | |
| 99 | +end | ... | ... |
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb