[issue #590] Merge branch 'master' into 590-build_list_page_change
Conflicts: db/schema.rb
This commit is contained in:
commit
6eff6bffa5
8
Gemfile
8
Gemfile
|
@ -1,6 +1,6 @@
|
|||
source 'http://rubygems.org'
|
||||
|
||||
gem 'rails', '3.2.6' #, :git => 'git://github.com/rails/rails.git'
|
||||
gem 'rails', '3.2.7' #, :git => 'git://github.com/rails/rails.git'
|
||||
|
||||
gem 'pg', '~> 0.14.0'
|
||||
# gem 'silent-postgres', :git => 'git://github.com/dolzenko/silent-postgres.git' #'~> 0.1.1'
|
||||
|
@ -31,7 +31,7 @@ gem 'github-linguist', '~> 2.1.2', :require => 'linguist'
|
|||
gem 'diff-display', '~> 0.0.1'
|
||||
|
||||
# Wiki
|
||||
gem "gollum", "1.3.1"
|
||||
gem "gollum", :git => 'git://github.com/github/gollum.git'
|
||||
gem "redcarpet", "1.17.2"
|
||||
gem 'creole'
|
||||
gem 'rdiscount'
|
||||
|
@ -41,7 +41,7 @@ gem 'wikicloth'
|
|||
|
||||
gem 'unicorn', '~> 4.3.1', :platforms => [:mri, :rbx]
|
||||
gem 'trinidad', '~> 1.0.2', :platforms => :jruby
|
||||
gem 'newrelic_rpm', '~> 3.4.0.1', :platforms => [:mri, :rbx]
|
||||
gem 'newrelic_rpm', '~> 3.4.1', :platforms => [:mri, :rbx]
|
||||
gem 'whenever', '~> 0.7.3', :require => false
|
||||
|
||||
gem 'jbuilder', '~> 0.4.0'
|
||||
|
@ -81,7 +81,7 @@ end
|
|||
|
||||
group :test do
|
||||
gem 'rspec-rails', '~> 2.11.0', :group => 'development'
|
||||
gem 'factory_girl_rails', '~> 3.5.0'
|
||||
gem 'factory_girl_rails', '~> 3.6.0'
|
||||
gem 'rr', '~> 1.0.4'
|
||||
gem 'shoulda'
|
||||
end
|
||||
|
|
101
Gemfile.lock
101
Gemfile.lock
|
@ -6,6 +6,23 @@ GIT
|
|||
redhillonrails_core (2.0.0.pre)
|
||||
activerecord (>= 3.1.0.rc)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/github/gollum.git
|
||||
revision: 8422b712048656c8ea391c2d7ef27fb29f66746b
|
||||
specs:
|
||||
gollum (2.1.0)
|
||||
github-markdown
|
||||
github-markup (>= 0.7.0, < 1.0.0)
|
||||
grit (~> 2.5.0)
|
||||
mustache (>= 0.11.2, < 1.0.0)
|
||||
nokogiri (~> 1.4)
|
||||
posix-spawn (~> 0.3.0)
|
||||
pygments.rb (~> 0.2.0)
|
||||
sanitize (~> 2.0.0)
|
||||
sinatra (~> 1.0)
|
||||
stringex (~> 1.4.0)
|
||||
useragent (~> 0.4.9)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rdblue/grack.git
|
||||
revision: 020be3fef3fb308b9d214252522aa5945bf6584a
|
||||
|
@ -14,9 +31,9 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/warpc/grit.git
|
||||
revision: 696b0967cb7e6bac044569d898e5acef431d4f97
|
||||
revision: f04f779fb052725b964ba259f8073a34e493c0c7
|
||||
specs:
|
||||
grit (2.4.1)
|
||||
grit (2.5.0)
|
||||
diff-lcs (~> 1.1)
|
||||
mime-types (~> 1.15)
|
||||
posix-spawn (~> 0.3.6)
|
||||
|
@ -25,38 +42,36 @@ GEM
|
|||
remote: http://rubygems.org/
|
||||
specs:
|
||||
RedCloth (4.2.9)
|
||||
actionmailer (3.2.6)
|
||||
actionpack (= 3.2.6)
|
||||
actionmailer (3.2.7)
|
||||
actionpack (= 3.2.7)
|
||||
mail (~> 2.4.4)
|
||||
actionpack (3.2.6)
|
||||
activemodel (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
actionpack (3.2.7)
|
||||
activemodel (= 3.2.7)
|
||||
activesupport (= 3.2.7)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
journey (~> 1.0.1)
|
||||
journey (~> 1.0.4)
|
||||
rack (~> 1.4.0)
|
||||
rack-cache (~> 1.2)
|
||||
rack-test (~> 0.6.1)
|
||||
sprockets (~> 2.1.3)
|
||||
activemodel (3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
activemodel (3.2.7)
|
||||
activesupport (= 3.2.7)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.6)
|
||||
activemodel (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
activerecord (3.2.7)
|
||||
activemodel (= 3.2.7)
|
||||
activesupport (= 3.2.7)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.6)
|
||||
activemodel (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
activesupport (3.2.6)
|
||||
activeresource (3.2.7)
|
||||
activemodel (= 3.2.7)
|
||||
activesupport (= 3.2.7)
|
||||
activesupport (3.2.7)
|
||||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
airbrake (3.1.2)
|
||||
activesupport
|
||||
builder
|
||||
albino (1.3.3)
|
||||
posix-spawn (>= 0.3.6)
|
||||
ancestry (1.3.0)
|
||||
activerecord (>= 2.3.14)
|
||||
arel (3.0.2)
|
||||
|
@ -110,10 +125,10 @@ GEM
|
|||
execjs (1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
expression_parser (0.9.0)
|
||||
factory_girl (3.5.0)
|
||||
factory_girl (3.6.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (3.5.0)
|
||||
factory_girl (~> 3.5.0)
|
||||
factory_girl_rails (3.6.0)
|
||||
factory_girl (~> 3.6.0)
|
||||
railties (>= 3.0.0)
|
||||
ffi (1.0.11)
|
||||
fssm (0.2.9)
|
||||
|
@ -122,16 +137,8 @@ GEM
|
|||
escape_utils (~> 0.2.3)
|
||||
mime-types (~> 1.18)
|
||||
pygments.rb (>= 0.2.13)
|
||||
github-markdown (0.5.0)
|
||||
github-markup (0.7.4)
|
||||
gollum (1.3.1)
|
||||
albino (~> 1.3.2)
|
||||
github-markup (>= 0.4.0, < 1.0.0)
|
||||
grit (~> 2.4.1)
|
||||
mustache (>= 0.11.2, < 1.0.0)
|
||||
nokogiri (~> 1.4)
|
||||
redcarpet
|
||||
sanitize (~> 2.0.0)
|
||||
sinatra (~> 1.0)
|
||||
haml (3.1.6)
|
||||
haml-rails (0.3.4)
|
||||
actionpack (~> 3.0)
|
||||
|
@ -180,7 +187,7 @@ GEM
|
|||
net-ssh (2.5.2)
|
||||
net-ssh-gateway (1.1.0)
|
||||
net-ssh (>= 1.99.1)
|
||||
newrelic_rpm (3.4.0.1)
|
||||
newrelic_rpm (3.4.1)
|
||||
nokogiri (1.5.5)
|
||||
omniauth (1.1.0)
|
||||
hashie (~> 1.2)
|
||||
|
@ -216,14 +223,14 @@ GEM
|
|||
rack
|
||||
rack-test (0.6.1)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.6)
|
||||
actionmailer (= 3.2.6)
|
||||
actionpack (= 3.2.6)
|
||||
activerecord (= 3.2.6)
|
||||
activeresource (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
rails (3.2.7)
|
||||
actionmailer (= 3.2.7)
|
||||
actionpack (= 3.2.7)
|
||||
activerecord (= 3.2.7)
|
||||
activeresource (= 3.2.7)
|
||||
activesupport (= 3.2.7)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.6)
|
||||
railties (= 3.2.7)
|
||||
rails-backbone (0.7.2)
|
||||
coffee-script (~> 2.2.0)
|
||||
ejs (~> 1.0.0)
|
||||
|
@ -232,9 +239,9 @@ GEM
|
|||
railties (>= 3.0.0)
|
||||
rails3-jquery-autocomplete (1.0.7)
|
||||
rails (~> 3.0)
|
||||
railties (3.2.6)
|
||||
actionpack (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
railties (3.2.7)
|
||||
actionpack (= 3.2.7)
|
||||
activesupport (= 3.2.7)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
|
@ -315,6 +322,7 @@ GEM
|
|||
tilt (~> 1.1, != 1.3.0)
|
||||
sqlite3 (1.3.6)
|
||||
state_machine (1.1.2)
|
||||
stringex (1.4.0)
|
||||
systemu (2.5.2)
|
||||
therubyracer (0.10.1)
|
||||
libv8 (~> 3.3.10)
|
||||
|
@ -335,6 +343,7 @@ GEM
|
|||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
useragent (0.4.10)
|
||||
uuid (2.3.5)
|
||||
macaddr (~> 1.0)
|
||||
vegas (0.1.11)
|
||||
|
@ -367,9 +376,9 @@ DEPENDENCIES
|
|||
creole
|
||||
devise (~> 2.1.2)
|
||||
diff-display (~> 0.0.1)
|
||||
factory_girl_rails (~> 3.5.0)
|
||||
factory_girl_rails (~> 3.6.0)
|
||||
github-linguist (~> 2.1.2)
|
||||
gollum (= 1.3.1)
|
||||
gollum!
|
||||
grack!
|
||||
grit!
|
||||
haml-rails (~> 0.3.4)
|
||||
|
@ -379,13 +388,13 @@ DEPENDENCIES
|
|||
jquery-rails (~> 2.0.2)
|
||||
mailcatcher
|
||||
meta-tags (~> 1.2.5)
|
||||
newrelic_rpm (~> 3.4.0.1)
|
||||
newrelic_rpm (~> 3.4.1)
|
||||
omniauth (~> 1.1.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
paperclip (~> 3.1.4)
|
||||
perform_later (~> 1.3.0)
|
||||
pg (~> 0.14.0)
|
||||
rails (= 3.2.6)
|
||||
rails (= 3.2.7)
|
||||
rails-backbone (~> 0.7.2)
|
||||
rails3-generators
|
||||
rails3-jquery-autocomplete (~> 1.0.7)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
class Platforms::KeyPairsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
load_and_authorize_resource :platform, :only => [:index]
|
||||
load_and_authorize_resource :only => [:create, :destroy]
|
||||
|
||||
def create
|
||||
@key_pair.user_id = current_user.id
|
||||
|
||||
if @key_pair.save
|
||||
flash[:notice] = t('flash.key_pairs.saved')
|
||||
else
|
||||
flash[:error] = t('flash.key_pairs.save_error')
|
||||
flash[:warning] = @key_pair.errors.full_messages.join('. ') unless @key_pair.errors.blank?
|
||||
end
|
||||
|
||||
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @key_pair.destroy
|
||||
flash[:notice] = t('flash.key_pairs.destroyed')
|
||||
else
|
||||
flash[:error] = t('flash.key_pairs.destroy_error')
|
||||
end
|
||||
|
||||
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
|
||||
end
|
||||
end
|
|
@ -54,7 +54,9 @@ module GitHelper
|
|||
current = url_for(p).split('?', 2).first
|
||||
|
||||
res = []
|
||||
res << [I18n.t('layout.git.repositories.commits'), [params[:treeish].truncate(20)]] unless project.repo.branches_and_tags.map(&:name).include?(params[:treeish] || project.default_branch)
|
||||
if params[:treeish].present? && !project.repo.branches_and_tags.map(&:name).include?(params[:treeish])
|
||||
res << [I18n.t('layout.git.repositories.commits'), [params[:treeish].truncate(20)]]
|
||||
end
|
||||
linking = Proc.new {|t| [t.name.truncate(20), url_for(p.merge :treeish => t.name).split('?', 2).first]}
|
||||
res << [I18n.t('layout.git.repositories.branches'), project.repo.branches.map(&linking)]
|
||||
res << [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&linking)]
|
||||
|
|
|
@ -17,7 +17,7 @@ class Ability
|
|||
can :archive, Project, :visibility => 'open'
|
||||
can :read, Issue, :project => {:visibility => 'open'}
|
||||
can :search, BuildList
|
||||
can :read, BuildList, :project => {:visibility => 'open'}
|
||||
can [:read, :everything], BuildList, :project => {:visibility => 'open'}
|
||||
can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
|
||||
can :read, Advisory
|
||||
can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
|
||||
|
@ -62,10 +62,10 @@ class Ability
|
|||
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')}
|
||||
can :remove_user, Project
|
||||
|
||||
can [:read, :owned], BuildList, :user_id => user.id
|
||||
can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
can [:read, :related], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can(:read, BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
|
||||
can [:read, :owned, :everything], BuildList, :user_id => user.id
|
||||
can [:read, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
can [:read, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can([:read, :everything], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
|
||||
can([:create, :update], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)}
|
||||
|
||||
can(:publish, BuildList) do |build_list|
|
||||
|
@ -97,6 +97,8 @@ class Ability
|
|||
can(:clear, Platform) {|platform| local_admin?(platform) && platform.personal?}
|
||||
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
|
||||
|
||||
can([:create, :destroy], KeyPair) {|key_pair| owner?(key_pair.repository.platform) || local_admin?(key_pair.repository.platform)}
|
||||
|
||||
can :read, Product, :platform => {:visibility => 'open'}
|
||||
can :read, Product, :platform => {:owner_type => 'User', :owner_id => user.id, :platform_type => 'main'}
|
||||
can :read, Product, :platform => {:owner_type => 'Group', :owner_id => user.group_ids, :platform_type => 'main'}
|
||||
|
|
|
@ -114,14 +114,16 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
# WTF? around_transition -> infinite loop
|
||||
before_transition do |build_list, transition|
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
|
||||
MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
|
||||
status = BuildList::HUMAN_STATUSES[build_list.status]
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
||||
MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||
end
|
||||
end
|
||||
|
||||
after_transition do |build_list, transition|
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
|
||||
MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
|
||||
status = BuildList::HUMAN_STATUSES[build_list.status]
|
||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
||||
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -52,8 +52,10 @@ class BuildList::Filter
|
|||
:mass_build_id => nil
|
||||
}))
|
||||
|
||||
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'index' : 'owned')
|
||||
@options[:status] = @options[:status].try(:to_i)
|
||||
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'everything' : 'owned')
|
||||
@options[:status] = @options[:status].present? ? @options[:status].to_i : nil
|
||||
@options[:created_at_start] = build_date_from_params(:created_at_start, @options)
|
||||
@options[:created_at_end] = build_date_from_params(:created_at_end, @options)
|
||||
@options[:updated_at_start] = build_date_from_params(:updated_at_start, @options)
|
||||
@options[:updated_at_end] = build_date_from_params(:updated_at_end, @options)
|
||||
@options[:project_version] = @options[:project_version].presence
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
class KeyPair < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
belongs_to :user
|
||||
|
||||
attr_accessor :secret
|
||||
attr_accessible :public, :secret, :repository_id
|
||||
|
||||
validates :repository_id, :public, :user_id, :presence => true
|
||||
validates :secret, :presence => true, :on => :create
|
||||
|
||||
validates :repository_id, :uniqueness => {:message => I18n.t("activerecord.errors.key_pair.repo_key_exists")}
|
||||
|
||||
before_create :key_create_call
|
||||
before_destroy :rm_key_call
|
||||
|
||||
protected
|
||||
|
||||
def key_create_call
|
||||
result, self.key_id = BuildServer.import_gpg_key_pair(public, secret)
|
||||
raise "Failed to create key_pairs for repository #{repository_id} with code #{result}." if result == 4
|
||||
if result != 0 || self.key_id.nil?
|
||||
errors.add(:public, I18n.t("activerecord.errors.key_pair.rpc_error_#{result}"))
|
||||
return false
|
||||
end
|
||||
result = BuildServer.set_repository_key(repository.platform.name, repository.name, self.key_id)
|
||||
raise "Failed to sign repository #{repository.name} in platform #{repository.platform.name}
|
||||
using key_id #{self.key_id} with code #{result}." unless result.zero?
|
||||
end
|
||||
|
||||
def rm_key_call
|
||||
result = BuildServer.rm_repository_key(repository.platform.name, repository.name)
|
||||
raise "Failed to desroy repository key #{repository.name} in platform
|
||||
#{repository.platform.name} with code #{result}." unless result.zero?
|
||||
end
|
||||
end
|
|
@ -4,6 +4,7 @@ class Repository < ActiveRecord::Base
|
|||
|
||||
has_many :project_to_repositories, :dependent => :destroy, :validate => true
|
||||
has_many :projects, :through => :project_to_repositories
|
||||
has_one :key_pair, :dependent => :destroy
|
||||
|
||||
validates :description, :presence => true
|
||||
validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => {:with => /^[a-z0-9_\-]+$/}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
- if can? :members, @platform
|
||||
%li{:class => (act == :members && contr == :platforms) ? 'active' : nil}
|
||||
= link_to t("layout.platforms.members"), members_platform_path(@platform)
|
||||
- if can? :edit, @platform
|
||||
%li{:class => (act == :index && contr == :key_pairs) ? 'active' : ''}
|
||||
= link_to t("layout.key_pairs.header"), platform_key_pairs_path(@platform)
|
||||
-#- if current_user.owner_of? @platform or current_user.admin?
|
||||
%li{:class => (act == :index && contr == :private_users) ? 'active' : ''}
|
||||
= link_to t("layout.platforms.private_users"), platform_private_users_path(@platform)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
%table#myTable.tablesorter.platform-repos{:cellspacing => "0", :cellpadding => "0"}
|
||||
%thead
|
||||
%tr
|
||||
%th.th1= t("activerecord.attributes.key_pair.repository_id")
|
||||
%th.th2= t("activerecord.attributes.key_pair.key_id")
|
||||
%th.th3= t("activerecord.attributes.key_pair.user_id")
|
||||
%th= t("layout.delete")
|
||||
%tbody
|
||||
- @platform.repositories.each do |repository|
|
||||
- if repository.key_pair
|
||||
%tr{:class => cycle("odd", "even")}
|
||||
%td= repository.name
|
||||
%td= repository.key_pair.key_id
|
||||
%td= link_to repository.key_pair.user.fullname, user_path(repository.key_pair.user)
|
||||
%td.buttons
|
||||
- if can? :destroy, repository.key_pair
|
||||
= link_to platform_key_pair_path(@platform, repository.key_pair), :method => :delete, :confirm => t("layout.key_pairs.confirm_delete") do
|
||||
%span.delete
|
|
@ -0,0 +1,17 @@
|
|||
= render 'platforms/base/sidebar'
|
||||
|
||||
%h3= t("layout.key_pairs.header")
|
||||
|
||||
= form_for :key_pair, :url => platform_key_pairs_path(@platform), :method => :post, :html => { :class => :form } do |f|
|
||||
.leftlist= f.label :public, t("activerecord.attributes.key_pair.public"), :class => :label
|
||||
.rightlist= f.text_area :public, :class => 'text_field resizable', :cols => 80
|
||||
.both
|
||||
.leftlist= f.label :secret, t("activerecord.attributes.key_pair.secret"), :class => :label
|
||||
.rightlist= f.text_area :secret, :class => 'text_field resizable', :cols => 80
|
||||
.both
|
||||
.leftlist= f.label :repository_id, t("activerecord.attributes.key_pair.repository_id"), :class => :label
|
||||
.rightlist= f.select :repository_id, options_from_collection_for_select(@platform.repositories, 'id', 'name')
|
||||
.both
|
||||
|
||||
.button_block
|
||||
= submit_tag t("layout.save")
|
|
@ -0,0 +1,2 @@
|
|||
= render 'new' if can? :edit, @platform
|
||||
= render 'list'
|
|
@ -37,13 +37,13 @@
|
|||
- @mass_builds.each do |mass_build|
|
||||
%tr
|
||||
%td= mass_build.id
|
||||
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id})
|
||||
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'})
|
||||
%td.min_width_120
|
||||
- MassBuild::COUNT_STATUSES.each do |status|
|
||||
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
|
||||
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
|
||||
= mass_build.read_attribute "#{status}_count"
|
||||
.both
|
||||
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id), :target => "_blank" if can?(:failed_builds_list, mass_build)
|
||||
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build)
|
||||
%td= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel, mass_build)
|
||||
%td
|
||||
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
.lefter= t("layout.build_lists.ownership.related")
|
||||
.both
|
||||
.table
|
||||
.lefter= f.radio_button :ownership, 'index', :class => 'niceRadio', :id => 'myradio3'
|
||||
.lefter= t("layout.build_lists.ownership.index")
|
||||
.lefter= f.radio_button :ownership, 'everything', :class => 'niceRadio', :id => 'myradio3'
|
||||
.lefter= t("layout.build_lists.ownership.everything")
|
||||
.both
|
||||
%br
|
||||
= f.submit t("layout.search.header")
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
%td.blob
|
||||
:plain
|
||||
<br/>
|
||||
<pre>#{link_to @blob.basename, raw_path(@project, @treeish, @path)}</pre>
|
||||
<pre>#{link_to_unless @blob.huge?, @blob.basename, raw_path(@project, @treeish, @path)}</pre>
|
||||
<br/>
|
|
@ -12,8 +12,9 @@
|
|||
- if @blob.render_as == :text && params[:action] != 'show'
|
||||
= link_to "Normal", blob_path(@project, @treeish, @path)
|
||||
\|
|
||||
= link_to "Raw", raw_path(@project, @treeish, @path)
|
||||
\|
|
||||
- unless @blob.huge?
|
||||
= link_to "Raw", raw_path(@project, @treeish, @path)
|
||||
\|
|
||||
- if @blob.render_as == :text && params[:action] != 'blame'
|
||||
= link_to "Blame", blame_path(@project, @treeish, @path)
|
||||
\|
|
||||
|
|
|
@ -48,7 +48,7 @@ module Rosa
|
|||
config.encoding = "utf-8"
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters += [:password]
|
||||
config.filter_parameters += [:password, :secret]
|
||||
|
||||
# Enable the asset pipeline
|
||||
config.assets.enabled = true
|
||||
|
|
|
@ -62,7 +62,7 @@ Rosa::Application.configure do
|
|||
config.assets.digest = true
|
||||
|
||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js)
|
||||
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js)
|
||||
end
|
||||
|
||||
# require 'stub_xml_rpc'
|
||||
|
|
|
@ -80,7 +80,7 @@ en:
|
|||
header: Build list ownership
|
||||
owned: My
|
||||
related: Related
|
||||
index: All
|
||||
everything: All
|
||||
|
||||
build_server_status:
|
||||
header: Build server status
|
||||
|
|
|
@ -79,7 +79,7 @@ ru:
|
|||
header: Принадлежность заданий
|
||||
owned: Мне
|
||||
related: Связанные со мной
|
||||
index: Все
|
||||
everything: Все
|
||||
|
||||
build_server_status:
|
||||
header: Статус сборочного сервера
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
en:
|
||||
layout:
|
||||
key_pairs:
|
||||
repository_id: Repository
|
||||
user_id: User
|
||||
public: Public key
|
||||
secret: Secret key
|
||||
confirm_delete: Are you sure you want to delete this signature?
|
||||
header: Signatures
|
||||
flash:
|
||||
key_pairs:
|
||||
saved: Repository successfully signed
|
||||
save_error: Signature save error
|
||||
destroyed: Signature succefully destroyed
|
||||
destroy_error: Signature destroy error
|
||||
activerecord:
|
||||
errors:
|
||||
key_pair:
|
||||
repo_key_exists: Repository has been signed already! Please remove old signature and try again
|
||||
rpc_error_0: an unexpected error
|
||||
rpc_error_1: could not import public key
|
||||
rpc_error_2: could not import secret key
|
||||
rpc_error_3: keys are imported, but it is not a key pair (ids differ)
|
||||
models:
|
||||
key_pair: Key Pair
|
||||
attributes:
|
||||
key_pair:
|
||||
id: Id
|
||||
created_at: Created
|
||||
updated_at: Updated
|
||||
user_id: User
|
||||
repository_id: Repository
|
||||
public: Public key
|
||||
secret: Secret key
|
||||
key_id: Signature
|
|
@ -0,0 +1,35 @@
|
|||
ru:
|
||||
layout:
|
||||
key_pairs:
|
||||
repository_id: Репозиторий
|
||||
user_id: Пользователь
|
||||
public: Публичный ключ
|
||||
secret: Секретный ключ
|
||||
confirm_delete: Вы уверены, что хотите удалить подпись?
|
||||
header: Подписи
|
||||
flash:
|
||||
key_pairs:
|
||||
saved: Репозиторий успешно подписан
|
||||
save_error: Ошибка создания подписи
|
||||
destroyed: Подпись успешно удалена
|
||||
destroy_error: Ошибка удаления подписи
|
||||
activerecord:
|
||||
errors:
|
||||
key_pair:
|
||||
repo_key_exists: Репозиторий уже подписан! Пожалуйста, удалите старую подпись и попробуйте снова
|
||||
rpc_error_0: Неизвестная ошибка
|
||||
rpc_error_1: Проблемы с импортром публичного ключа
|
||||
rpc_error_2: Проблемы с импортром секретного ключа
|
||||
rpc_error_3: Ключи импортированы, но не являются парой (идентификаторы не совпадают)
|
||||
models:
|
||||
key_pair: Подпись
|
||||
attributes:
|
||||
key_pair:
|
||||
id: Id
|
||||
created_at: Создано
|
||||
updated_at: Обновлено
|
||||
user_id: Пользователь
|
||||
repository_id: Репозиторий
|
||||
public: Публичный ключ
|
||||
secret: Секретный ключ
|
||||
key_id: Подпись
|
|
@ -72,6 +72,7 @@ Rosa::Application.routes.draw do
|
|||
get :projects_list
|
||||
end
|
||||
end
|
||||
resources :key_pairs, :only => [:create, :index, :destroy]
|
||||
resources :products do
|
||||
resources :product_build_lists, :only => [:create, :destroy]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class CreateKeyPairs < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :key_pairs do |t|
|
||||
t.integer :repository_id
|
||||
t.integer :user_id
|
||||
t.integer :key_id
|
||||
t.string :public
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class SetTextTypeForKeyPairsPublic < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :key_pairs, :public, :text
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :key_pairs, :public, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class SetStringTypeForKeyPairsKeyid < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :key_pairs, :key_id, :string
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :key_pairs, :key_id, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
class DisableNullValueForKeyPairs < ActiveRecord::Migration
|
||||
def up
|
||||
change_column_null :key_pairs, :repository_id, false
|
||||
change_column_null :key_pairs, :user_id, false
|
||||
change_column_null :key_pairs, :key_id, false
|
||||
change_column_null :key_pairs, :public, false
|
||||
add_index :key_pairs, :repository_id, :unique => true
|
||||
end
|
||||
|
||||
def down
|
||||
change_column_null :key_pairs, :repository_id, true
|
||||
change_column_null :key_pairs, :user_id, true
|
||||
change_column_null :key_pairs, :key_id, true
|
||||
change_column_null :key_pairs, :public, true
|
||||
remove_index :key_pairs, :repository_id
|
||||
end
|
||||
end
|
72
db/schema.rb
72
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120727141521) do
|
||||
ActiveRecord::Schema.define(:version => 20120730214052) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -169,10 +169,12 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
|
||||
|
||||
create_table "groups", :force => true do |t|
|
||||
t.integer "owner_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "uname"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.text "description"
|
||||
|
@ -185,8 +187,8 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.string "title"
|
||||
t.text "body"
|
||||
t.string "status", :default => "open"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "user_id"
|
||||
t.datetime "closed_at"
|
||||
t.integer "closed_by"
|
||||
|
@ -194,6 +196,17 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
|
||||
add_index "issues", ["project_id", "serial_id"], :name => "index_issues_on_project_id_and_serial_id", :unique => true
|
||||
|
||||
create_table "key_pairs", :force => true do |t|
|
||||
t.integer "repository_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.string "key_id", :null => false
|
||||
t.text "public", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "key_pairs", ["repository_id"], :name => "index_key_pairs_on_repository_id", :unique => true
|
||||
|
||||
create_table "labelings", :force => true do |t|
|
||||
t.integer "label_id", :null => false
|
||||
t.integer "issue_id"
|
||||
|
@ -251,16 +264,16 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.integer "platform_id"
|
||||
t.string "login"
|
||||
t.string "password"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
create_table "product_build_lists", :force => true do |t|
|
||||
t.integer "product_id"
|
||||
t.integer "status", :default => 2, :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"
|
||||
|
@ -268,8 +281,8 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
create_table "products", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.integer "platform_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.text "build_script"
|
||||
t.text "counter"
|
||||
t.text "ks"
|
||||
|
@ -288,8 +301,8 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.string "name"
|
||||
t.string "version"
|
||||
t.datetime "file_mtime"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "platform_id"
|
||||
end
|
||||
|
||||
|
@ -298,14 +311,14 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
create_table "project_to_repositories", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.integer "repository_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "projects", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "owner_id"
|
||||
t.string "owner_type"
|
||||
t.string "visibility", :default => "open"
|
||||
|
@ -331,8 +344,8 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.string "token"
|
||||
t.boolean "approved", :default => false
|
||||
t.boolean "rejected", :default => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "interest"
|
||||
t.text "more"
|
||||
end
|
||||
|
@ -345,16 +358,16 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.string "actor_type"
|
||||
t.integer "target_id"
|
||||
t.string "target_type"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "role"
|
||||
end
|
||||
|
||||
create_table "repositories", :force => true do |t|
|
||||
t.string "description", :null => false
|
||||
t.integer "platform_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "name", :null => false
|
||||
end
|
||||
|
||||
|
@ -365,8 +378,8 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.boolean "new_comment_reply", :default => true
|
||||
t.boolean "new_issue", :default => true
|
||||
t.boolean "issue_assign", :default => true
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "new_comment_commit_owner", :default => true
|
||||
t.boolean "new_comment_commit_repo_owner", :default => true
|
||||
t.boolean "new_comment_commit_commentor", :default => true
|
||||
|
@ -375,8 +388,8 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
create_table "subscribes", :force => true do |t|
|
||||
t.string "subscribeable_type"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "status", :default => true
|
||||
t.integer "project_id"
|
||||
t.decimal "subscribeable_id", :precision => 50, :scale => 0
|
||||
|
@ -386,11 +399,12 @@ ActiveRecord::Schema.define(:version => 20120727141521) do
|
|||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
|
|
|
@ -25,4 +25,6 @@ sudo urpmi lib64magic-devel # mandriva
|
|||
brew install libmagic; brew link libmagic # brew
|
||||
gem install ruby-filemagic
|
||||
|
||||
sudo urpmi python-devel
|
||||
|
||||
git config --global core.quotepath false
|
||||
|
|
|
@ -87,11 +87,11 @@ class BuildServer
|
|||
# raise include_repos_hash.inspect
|
||||
self.client.call('add_build_list', project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos_hash, priority)
|
||||
end
|
||||
|
||||
|
||||
def self.delete_build_list idlist
|
||||
self.client.call('delete_build_list', idlist)
|
||||
end
|
||||
|
||||
|
||||
def self.get_status
|
||||
self.client.call('get_status')
|
||||
end
|
||||
|
@ -99,4 +99,17 @@ class BuildServer
|
|||
def self.freeze platform_name
|
||||
self.client.call('freeze_platform', platform_name)
|
||||
end
|
||||
|
||||
# Repository key pair calls
|
||||
def self.import_gpg_key_pair key_pub, key_secret
|
||||
self.client.call('import_gpg_key_pair', key_pub, key_secret)
|
||||
end
|
||||
|
||||
def self.set_repository_key platform, repository, key_id
|
||||
self.client.call('set_repository_key', platform, repository, key_id)
|
||||
end
|
||||
|
||||
def self.rm_repository_key platform, repository
|
||||
self.client.call('rm_repository_key', platform, repository)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,9 +15,10 @@ class String
|
|||
encode!(Encoding::UTF_16, default_encoding, options).encode!(default_encoding, Encoding::UTF_16)
|
||||
raise unless valid_encoding? # check result
|
||||
end
|
||||
self
|
||||
rescue
|
||||
replace "--broken encoding: #{detect_encoding[:encoding] || 'unknown'}"
|
||||
ensure
|
||||
self
|
||||
# ensure
|
||||
# return self
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module Grit
|
|||
MAX_DATA_SIZE = 50.megabytes
|
||||
|
||||
def data_with_limit
|
||||
size <= MAX_DATA_SIZE ? data_without_limit : nil # 'Error: blob is too big'
|
||||
!huge? ? data_without_limit : nil # 'Error: blob is too big'
|
||||
end
|
||||
alias_method_chain :data, :limit
|
||||
|
||||
|
@ -15,6 +15,10 @@ module Grit
|
|||
size.to_i > MAX_VIEW_SIZE
|
||||
end
|
||||
|
||||
def huge?
|
||||
size.to_i > MAX_DATA_SIZE
|
||||
end
|
||||
|
||||
def render_as
|
||||
@render_as ||= case
|
||||
when large?; :binary
|
||||
|
|
|
@ -21,11 +21,10 @@ module Rosa
|
|||
|
||||
class Treeish
|
||||
def self.matches?(request)
|
||||
params = request.path_parameters
|
||||
if params[:treeish] # parse existing branch (tag) and path
|
||||
if (params = request.path_parameters) && params[:treeish] # parse existing branch (tag) and path
|
||||
branch_or_tag = begin
|
||||
(p = Project.find_by_owner_and_name params[:owner_name], params[:project_name]) &&
|
||||
p.repo.branches_and_tags.detect{|t| params[:treeish].start_with?(t.name)}.try(:name) ||
|
||||
p.repo.branches_and_tags.map(&:name).sort{|a,b| b.length <=> a.length}.detect{|b| params[:treeish].start_with?(b)} ||
|
||||
params[:treeish].split('/').first
|
||||
end
|
||||
if path = params[:treeish].sub(branch_or_tag, '')[1..-1] and path.present?
|
||||
|
|
|
@ -5,7 +5,7 @@ module Modules
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_create :create_wiki
|
||||
after_save :create_wiki
|
||||
after_destroy :destroy_wiki
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
require 'spec_helper'
|
||||
|
||||
def create_key_pair(repository, user)
|
||||
@key_pair = FactoryGirl.create(:key_pair, :repository => repository, :user => user)
|
||||
end
|
||||
|
||||
shared_examples_for 'key_pair platform owner' do
|
||||
it 'should be able to perform index action' do
|
||||
get :index, :platform_id => @platform
|
||||
response.should render_template(:index)
|
||||
end
|
||||
|
||||
it 'should be able to perform create action' do
|
||||
post :create, @create_params
|
||||
response.should redirect_to(platform_key_pairs_path(@platform))
|
||||
end
|
||||
|
||||
it 'should create key pair into db on create action' do
|
||||
lambda { post :create, @create_params }.should change{KeyPair.count}.by(1)
|
||||
end
|
||||
|
||||
context "on destroy" do
|
||||
before(:each) do
|
||||
create_key_pair @repository, @user
|
||||
end
|
||||
|
||||
it 'should be able to perform action' do
|
||||
delete :destroy, :platform_id => @platform, :id => @key_pair
|
||||
response.should redirect_to(platform_key_pairs_path(@platform))
|
||||
end
|
||||
|
||||
it 'should delete key pair into db' do
|
||||
lambda { delete :destroy, :platform_id => @platform, :id => @key_pair }.should change{KeyPair.count}.by(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'key_pair platform reader' do
|
||||
it 'should be able to perform index action' do
|
||||
get :index, :platform_id => @platform
|
||||
response.should render_template(:index)
|
||||
end
|
||||
|
||||
it 'should not be able to perform create action' do
|
||||
post :create, @create_params
|
||||
response.should redirect_to(forbidden_path)
|
||||
end
|
||||
|
||||
it 'should not change objects count on create success' do
|
||||
lambda { post :create, @create_params }.should change{ KeyPair.count }.by(0)
|
||||
end
|
||||
|
||||
context "on destroy" do
|
||||
before(:each) do
|
||||
create_key_pair @repository, @user
|
||||
end
|
||||
|
||||
it 'should not be able to perform action' do
|
||||
delete :destroy, :platform_id => @platform, :id => @key_pair
|
||||
response.should redirect_to(forbidden_path)
|
||||
end
|
||||
|
||||
it 'should not change objects count on destroy success' do
|
||||
lambda { delete :destroy, :platform_id => @platform, :id => @key_pair }.should change{KeyPair.count}.by(0)
|
||||
end
|
||||
end
|
||||
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)
|
||||
@create_params = {
|
||||
:platform_id => @platform,
|
||||
:key_pair => {
|
||||
:repository_id => @repository,
|
||||
:public => "iampublic",
|
||||
:secret => "iamsecret"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
context 'for guest' do
|
||||
[:index, :create].each do |action|
|
||||
it "should not be able to perform #{ action } action" do
|
||||
get action, :platform_id => @platform
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not change objects count on create success' do
|
||||
lambda { post :create, @create_params }.should change{ KeyPair.count }.by(0)
|
||||
end
|
||||
|
||||
context 'on destroy' do
|
||||
before(:each) do
|
||||
create_key_pair @repository, @user
|
||||
end
|
||||
|
||||
it 'should not change objects count on destroy success' do
|
||||
lambda { delete :destroy, :platform_id => @platform, :id => @key_pair }.should change{KeyPair.count}.by(0)
|
||||
end
|
||||
|
||||
it "should not be able to perform destroy action" do
|
||||
delete :destroy, :platform_id => @platform, :id => @key_pair
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'for global admin' do
|
||||
before(:each) do
|
||||
@admin = FactoryGirl.create(:admin)
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@admin)
|
||||
end
|
||||
|
||||
it_should_behave_like 'key_pair platform owner'
|
||||
end
|
||||
|
||||
context 'for owner user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@platform.update_attribute(:owner, @user)
|
||||
end
|
||||
|
||||
it_should_behave_like 'key_pair platform owner'
|
||||
end
|
||||
|
||||
context 'for admin user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'key_pair platform owner'
|
||||
end
|
||||
|
||||
context 'for reader user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'key_pair platform reader'
|
||||
end
|
||||
|
||||
end
|
|
@ -125,7 +125,7 @@ describe Projects::BuildListsController do
|
|||
end
|
||||
|
||||
it 'should show only accessible build_lists' do
|
||||
get :index, :filter => {:ownership => 'index'}
|
||||
get :index, :filter => {:ownership => 'everything'}
|
||||
assigns(:build_lists).should include(@build_list1)
|
||||
assigns(:build_lists).should_not include(@build_list2)
|
||||
assigns(:build_lists).should include(@build_list3)
|
||||
|
@ -210,7 +210,7 @@ describe Projects::BuildListsController do
|
|||
end
|
||||
|
||||
it 'should show only accessible build_lists' do
|
||||
get :index, :filter => {:ownership => 'index'}
|
||||
get :index, :filter => {:ownership => 'everything'}
|
||||
assigns(:build_lists).should include(@build_list1)
|
||||
assigns(:build_lists).should_not include(@build_list2)
|
||||
assigns(:build_lists).should include(@build_list3)
|
||||
|
@ -297,17 +297,17 @@ describe Projects::BuildListsController do
|
|||
|
||||
it 'should filter by project_name' do
|
||||
# Project.where(:id => build_list2.project.id).update_all(:name => 'project_name')
|
||||
get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'index'}
|
||||
get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'everything'}
|
||||
assigns[:build_lists].should_not include(@build_list1)
|
||||
assigns[:build_lists].should include(@build_list2)
|
||||
assigns[:build_lists].should_not include(@build_list3)
|
||||
end
|
||||
|
||||
it 'should filter by project_name and start_date' do
|
||||
get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'index',
|
||||
:"updated_at_start(1i)" => @build_list3.updated_at.year.to_s,
|
||||
:"updated_at_start(2i)" => @build_list3.updated_at.month.to_s,
|
||||
:"updated_at_start(3i)" => @build_list3.updated_at.day.to_s}
|
||||
it 'should filter by project_name and update_date' do
|
||||
get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'everything',
|
||||
"updated_at_start(1i)" => @build_list3.updated_at.year.to_s,
|
||||
"updated_at_start(2i)" => @build_list3.updated_at.month.to_s,
|
||||
"updated_at_start(3i)" => @build_list3.updated_at.day.to_s}
|
||||
assigns[:build_lists].should_not include(@build_list1)
|
||||
assigns[:build_lists].should_not include(@build_list2)
|
||||
assigns[:build_lists].should include(@build_list3)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
FactoryGirl.define do
|
||||
factory :key_pair do
|
||||
association :repository
|
||||
association :user
|
||||
public FactoryGirl.generate(:string)
|
||||
secret FactoryGirl.generate(:string)
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe KeyPair do
|
||||
before(:all) do
|
||||
stub_symlink_methods
|
||||
stub_key_pairs_calls
|
||||
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
|
|
@ -38,6 +38,12 @@ 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
|
||||
|
||||
def test_git_commit(project)
|
||||
project.repo.index.add('test', 'TEST')
|
||||
project.repo.index.commit('Test commit')
|
||||
|
|
|
@ -241,7 +241,7 @@
|
|||
}
|
||||
|
||||
// attempt to load the definition for this language
|
||||
var script_uri = '/javascripts/gollum/editor/langs/' + markup_name + '.js';
|
||||
var script_uri = '/assets/gollum/editor/langs/' + markup_name + '.js';
|
||||
$.ajax({
|
||||
url: script_uri,
|
||||
dataType: 'script',
|
||||
|
|
Loading…
Reference in New Issue