diff --git a/app/assets/javascripts/platforms/key_pairs.js.coffee b/app/assets/javascripts/platforms/key_pairs.js.coffee deleted file mode 100644 index 761567942..000000000 --- a/app/assets/javascripts/platforms/key_pairs.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/platforms/key_pairs.css.scss b/app/assets/stylesheets/platforms/key_pairs.css.scss deleted file mode 100644 index d5b1aec6a..000000000 --- a/app/assets/stylesheets/platforms/key_pairs.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Platforms::KeyPairs controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/helpers/platforms/key_pairs_helper.rb b/app/helpers/platforms/key_pairs_helper.rb deleted file mode 100644 index cef406c92..000000000 --- a/app/helpers/platforms/key_pairs_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Platforms::KeyPairsHelper -end diff --git a/app/models/key_pair.rb b/app/models/key_pair.rb index 7fc7aad05..ec85e53fc 100644 --- a/app/models/key_pair.rb +++ b/app/models/key_pair.rb @@ -23,11 +23,7 @@ class KeyPair < ActiveRecord::Base end def rm_key_call - if BuildServer.rm_repository_key(repository.platform_id, repository_id) == 0 - self.destroy - return true - end - + return self.destroy if BuildServer.rm_repository_key(repository.platform_id, repository_id) == 0 false end end diff --git a/app/models/user.rb b/app/models/user.rb index ede3710e6..c807cfbac 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,6 +35,8 @@ class User < ActiveRecord::Base has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy + has_many :key_pairs + validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /^[a-z0-9_]+$/}, :reserved_name => true validate { errors.add(:uname, :taken) if Group.by_uname(uname).present? } validates :role, :inclusion => {:in => ROLES}, :allow_blank => true diff --git a/spec/helpers/platforms/key_pairs_helper_spec.rb b/spec/helpers/platforms/key_pairs_helper_spec.rb deleted file mode 100644 index a2ba0ac62..000000000 --- a/spec/helpers/platforms/key_pairs_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the Platforms::KeyPairsHelper. For example: -# -# describe Platforms::KeyPairsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe Platforms::KeyPairsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/key_pair_spec.rb b/spec/models/key_pair_spec.rb index 348480097..bda634ebe 100644 --- a/spec/models/key_pair_spec.rb +++ b/spec/models/key_pair_spec.rb @@ -1,5 +1,21 @@ require 'spec_helper' describe KeyPair do - pending "add some examples to (or delete) #{__FILE__}" + before(:all) do + stub_symlink_methods + FactoryGirl.create(:key_pair) + end + + it { should belong_to(:repository) } + it { should belong_to(:user)} + + it { should_not allow_mass_assignment_of(:user) } + it { should_not allow_mass_assignment_of(:key_id) } + + after(:all) do + Platform.delete_all + User.delete_all + Product.delete_all + FileUtils.rm_rf(APP_CONFIG['root_path']) + end end