diff --git a/Gemfile b/Gemfile index 0ace218c6..60869b4bb 100644 --- a/Gemfile +++ b/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 diff --git a/Gemfile.lock b/Gemfile.lock index 1ff9bd23d..896f7a8ab 100644 --- a/Gemfile.lock +++ b/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) diff --git a/app/controllers/platforms/key_pairs_controller.rb b/app/controllers/platforms/key_pairs_controller.rb new file mode 100644 index 000000000..4d9fb0ab0 --- /dev/null +++ b/app/controllers/platforms/key_pairs_controller.rb @@ -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 diff --git a/app/helpers/git_helper.rb b/app/helpers/git_helper.rb index 753db6e64..853c69b8a 100644 --- a/app/helpers/git_helper.rb +++ b/app/helpers/git_helper.rb @@ -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)] diff --git a/app/models/ability.rb b/app/models/ability.rb index c9e9d8ab7..6a0d2d96c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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'} diff --git a/app/models/build_list.rb b/app/models/build_list.rb index f1ad3b1f0..25509ad0e 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -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 diff --git a/app/models/build_list/filter.rb b/app/models/build_list/filter.rb index 48f0b59cc..345a138dc 100644 --- a/app/models/build_list/filter.rb +++ b/app/models/build_list/filter.rb @@ -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 diff --git a/app/models/key_pair.rb b/app/models/key_pair.rb new file mode 100644 index 000000000..25c5c50d5 --- /dev/null +++ b/app/models/key_pair.rb @@ -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 diff --git a/app/models/repository.rb b/app/models/repository.rb index 57c741790..491d219e8 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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_\-]+$/} 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/app/views/platforms/base/_sidebar.html.haml b/app/views/platforms/base/_sidebar.html.haml index 434e2ad43..35916f520 100644 --- a/app/views/platforms/base/_sidebar.html.haml +++ b/app/views/platforms/base/_sidebar.html.haml @@ -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) diff --git a/app/views/platforms/key_pairs/_list.html.haml b/app/views/platforms/key_pairs/_list.html.haml new file mode 100644 index 000000000..ca39da716 --- /dev/null +++ b/app/views/platforms/key_pairs/_list.html.haml @@ -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   diff --git a/app/views/platforms/key_pairs/_new.html.haml b/app/views/platforms/key_pairs/_new.html.haml new file mode 100644 index 000000000..b740fe218 --- /dev/null +++ b/app/views/platforms/key_pairs/_new.html.haml @@ -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") diff --git a/app/views/platforms/key_pairs/index.html.haml b/app/views/platforms/key_pairs/index.html.haml new file mode 100644 index 000000000..b04743a34 --- /dev/null +++ b/app/views/platforms/key_pairs/index.html.haml @@ -0,0 +1,2 @@ += render 'new' if can? :edit, @platform += render 'list' diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 15ba91f7a..e1115e0fa 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -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") diff --git a/app/views/projects/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml index 0d7d38eaa..a9ca14988 100644 --- a/app/views/projects/build_lists/_filter.html.haml +++ b/app/views/projects/build_lists/_filter.html.haml @@ -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") diff --git a/app/views/projects/git/blobs/_render_as_binary.html.haml b/app/views/projects/git/blobs/_render_as_binary.html.haml index bd7379a10..a8fd16a3d 100644 --- a/app/views/projects/git/blobs/_render_as_binary.html.haml +++ b/app/views/projects/git/blobs/_render_as_binary.html.haml @@ -4,5 +4,5 @@ %td.blob :plain
-
#{link_to @blob.basename, raw_path(@project, @treeish, @path)}
+
#{link_to_unless @blob.huge?, @blob.basename, raw_path(@project, @treeish, @path)}

\ No newline at end of file diff --git a/app/views/projects/git/blobs/_top.html.haml b/app/views/projects/git/blobs/_top.html.haml index 3fa62790b..f770185d2 100644 --- a/app/views/projects/git/blobs/_top.html.haml +++ b/app/views/projects/git/blobs/_top.html.haml @@ -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) \| diff --git a/config/application.rb b/config/application.rb index 0ec322cea..3cfd1ce68 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 diff --git a/config/environments/production.rb b/config/environments/production.rb index 37372580c..b3ca044d1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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' diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 6a34964ca..122684509 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -80,7 +80,7 @@ en: header: Build list ownership owned: My related: Related - index: All + everything: All build_server_status: header: Build server status diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index db0ec6781..94d54da58 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -79,7 +79,7 @@ ru: header: Принадлежность заданий owned: Мне related: Связанные со мной - index: Все + everything: Все build_server_status: header: Статус сборочного сервера diff --git a/config/locales/models/key_pair.en.yml b/config/locales/models/key_pair.en.yml new file mode 100644 index 000000000..9b685612a --- /dev/null +++ b/config/locales/models/key_pair.en.yml @@ -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 diff --git a/config/locales/models/key_pair.ru.yml b/config/locales/models/key_pair.ru.yml new file mode 100644 index 000000000..465ab0052 --- /dev/null +++ b/config/locales/models/key_pair.ru.yml @@ -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: Подпись diff --git a/config/routes.rb b/config/routes.rb index 1b391b6e0..3540d589a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20120710134434_create_key_pairs.rb b/db/migrate/20120710134434_create_key_pairs.rb new file mode 100644 index 000000000..50c41b1b0 --- /dev/null +++ b/db/migrate/20120710134434_create_key_pairs.rb @@ -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 diff --git a/db/migrate/20120730150317_set_text_type_for_key_pairs_public.rb b/db/migrate/20120730150317_set_text_type_for_key_pairs_public.rb new file mode 100644 index 000000000..1492d5feb --- /dev/null +++ b/db/migrate/20120730150317_set_text_type_for_key_pairs_public.rb @@ -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 diff --git a/db/migrate/20120730185119_set_string_type_for_key_pairs_keyid.rb b/db/migrate/20120730185119_set_string_type_for_key_pairs_keyid.rb new file mode 100644 index 000000000..da6337e16 --- /dev/null +++ b/db/migrate/20120730185119_set_string_type_for_key_pairs_keyid.rb @@ -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 diff --git a/db/migrate/20120730214052_disable_null_value_for_key_pairs.rb b/db/migrate/20120730214052_disable_null_value_for_key_pairs.rb new file mode 100644 index 000000000..e1d71ec52 --- /dev/null +++ b/db/migrate/20120730214052_disable_null_value_for_key_pairs.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 5406a0893..83f5c712f 100644 --- a/db/schema.rb +++ b/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" diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP index cca71ab75..cd837c6bc 100644 --- a/doc/README_FOR_APP +++ b/doc/README_FOR_APP @@ -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 diff --git a/lib/build_server.rb b/lib/build_server.rb index a1214af13..53dc35a63 100644 --- a/lib/build_server.rb +++ b/lib/build_server.rb @@ -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 diff --git a/lib/ext/core/string.rb b/lib/ext/core/string.rb index e84bca715..9ff9bde77 100644 --- a/lib/ext/core/string.rb +++ b/lib/ext/core/string.rb @@ -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 diff --git a/lib/ext/git/grit.rb b/lib/ext/git/grit.rb index 4fa2f11f3..3ec533062 100644 --- a/lib/ext/git/grit.rb +++ b/lib/ext/git/grit.rb @@ -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 diff --git a/lib/ext/rosa/constraints.rb b/lib/ext/rosa/constraints.rb index 54e9e6191..df007e540 100644 --- a/lib/ext/rosa/constraints.rb +++ b/lib/ext/rosa/constraints.rb @@ -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? diff --git a/lib/modules/models/wiki.rb b/lib/modules/models/wiki.rb index 1f13446b9..ef8884708 100644 --- a/lib/modules/models/wiki.rb +++ b/lib/modules/models/wiki.rb @@ -5,7 +5,7 @@ module Modules extend ActiveSupport::Concern included do - after_create :create_wiki + after_save :create_wiki after_destroy :destroy_wiki end diff --git a/spec/controllers/platforms/key_pairs_controller_spec.rb b/spec/controllers/platforms/key_pairs_controller_spec.rb new file mode 100644 index 000000000..5b27e41b0 --- /dev/null +++ b/spec/controllers/platforms/key_pairs_controller_spec.rb @@ -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 diff --git a/spec/controllers/projects/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb index ef95a4cf7..b2aa0d17d 100644 --- a/spec/controllers/projects/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -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) diff --git a/spec/factories/key_pair.rb b/spec/factories/key_pair.rb new file mode 100644 index 000000000..07adb4727 --- /dev/null +++ b/spec/factories/key_pair.rb @@ -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 + diff --git a/spec/models/key_pair_spec.rb b/spec/models/key_pair_spec.rb new file mode 100644 index 000000000..1bf3b9c2b --- /dev/null +++ b/spec/models/key_pair_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 72f943b66..a29d72fa6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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') diff --git a/vendor/assets/javascripts/gollum/editor/gollum.editor.js b/vendor/assets/javascripts/gollum/editor/gollum.editor.js index 075887eab..f7ddc6012 100755 --- a/vendor/assets/javascripts/gollum/editor/gollum.editor.js +++ b/vendor/assets/javascripts/gollum/editor/gollum.editor.js @@ -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',