From 0ad9932561781709856e7c78993efc303a86b8c1 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 20 Dec 2012 22:50:55 +0400 Subject: [PATCH] #794: fixes for failed specs --- Gemfile | 1 + Gemfile.lock | 2 ++ spec/controllers/api/v1/repositories_controller_spec.rb | 8 ++++---- spec/controllers/platforms/key_pairs_controller_spec.rb | 6 +++--- .../platforms/product_build_lists_controller_spec.rb | 2 ++ spec/models/key_pair_spec.rb | 1 - spec/spec_helper.rb | 6 ------ 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index a6bb3f7f0..25f8b4d30 100644 --- a/Gemfile +++ b/Gemfile @@ -89,4 +89,5 @@ group :test do gem 'factory_girl_rails', '~> 4.0.0' gem 'rr', '~> 1.0.4' gem 'shoulda' + gem 'mock_redis', '0.6.2' end diff --git a/Gemfile.lock b/Gemfile.lock index c5579510d..19fc100e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -175,6 +175,7 @@ GEM meta-tags (1.2.6) actionpack mime-types (1.19) + mock_redis (0.6.2) multi_json (1.5.0) mustache (0.99.4) net-scp (1.0.4) @@ -391,6 +392,7 @@ DEPENDENCIES jquery-rails (~> 2.0.2) mailcatcher meta-tags (~> 1.2.5) + mock_redis (= 0.6.2) newrelic_rpm (~> 3.4.1) omniauth (~> 1.1.0) omniauth-openid (~> 1.0.1) diff --git a/spec/controllers/api/v1/repositories_controller_spec.rb b/spec/controllers/api/v1/repositories_controller_spec.rb index ff46685f3..fac89600e 100644 --- a/spec/controllers/api/v1/repositories_controller_spec.rb +++ b/spec/controllers/api/v1/repositories_controller_spec.rb @@ -127,8 +127,8 @@ shared_examples_for 'api repository user with writer rights' do context 'api repository user with update signatures rights' do before do - stub_key_pairs_calls - put :signatures, :id => @repository.id, :repository => {:public => 'iampublic', :secret => 'iamsecret'}, :format => :json + kp = FactoryGirl.build(:key_pair) + put :signatures, :id => @repository.id, :repository => {:public => kp.public, :secret => kp.secret}, :format => :json end it 'should be able to perform signatures action' do response.should be_success @@ -228,8 +228,8 @@ shared_examples_for 'api repository user without writer rights' do context 'api repository user without update signatures rights' do before do - stub_key_pairs_calls - put :signatures, :id => @repository.id, :repository => {:public => 'iampublic', :secret => 'iamsecret'}, :format => :json + kp = FactoryGirl.build(:key_pair) + put :signatures, :id => @repository.id, :repository => {:public => kp.public, :secret => kp.secret}, :format => :json end it 'should not be able to perform signatures action' do response.should_not be_success diff --git a/spec/controllers/platforms/key_pairs_controller_spec.rb b/spec/controllers/platforms/key_pairs_controller_spec.rb index e9b73fc97..41db3bb24 100644 --- a/spec/controllers/platforms/key_pairs_controller_spec.rb +++ b/spec/controllers/platforms/key_pairs_controller_spec.rb @@ -69,17 +69,17 @@ end describe Platforms::KeyPairsController do before(:each) do stub_symlink_methods - stub_key_pairs_calls @platform = FactoryGirl.create(:platform) @repository = FactoryGirl.create(:repository, :platform => @platform) @user = FactoryGirl.create(:user) + kp = FactoryGirl.build(:key_pair) @create_params = { :platform_id => @platform, :key_pair => { :repository_id => @repository, - :public => "iampublic", - :secret => "iamsecret" + :public => kp.public, + :secret => kp.secret } } end diff --git a/spec/controllers/platforms/product_build_lists_controller_spec.rb b/spec/controllers/platforms/product_build_lists_controller_spec.rb index 0a0330aa7..0731036f3 100644 --- a/spec/controllers/platforms/product_build_lists_controller_spec.rb +++ b/spec/controllers/platforms/product_build_lists_controller_spec.rb @@ -84,6 +84,8 @@ end describe Platforms::ProductBuildListsController do before(:each) do stub_symlink_methods + redis_instance = MockRedis.new + stub(Redis).new { redis_instance } end context 'crud' do diff --git a/spec/models/key_pair_spec.rb b/spec/models/key_pair_spec.rb index 9d8b405f8..63e6a5b15 100644 --- a/spec/models/key_pair_spec.rb +++ b/spec/models/key_pair_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe KeyPair do before(:all) do stub_symlink_methods - stub_key_pairs_calls FactoryGirl.create(:key_pair) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4b2afc8ce..c9e501e87 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -46,12 +46,6 @@ def stub_symlink_methods any_instance_of(Platform, :remove_symlink_directory => true) end -def stub_key_pairs_calls - stub(BuildServer).import_gpg_key_pair { [0,"1a2b3c"] } - stub(BuildServer).set_repository_key { 0 } - stub(BuildServer).rm_repository_key { 0 } -end - Resque.inline = true def init_test_root