diff --git a/Gemfile b/Gemfile index 7fee616c9..bc1ea4404 100644 --- a/Gemfile +++ b/Gemfile @@ -24,8 +24,8 @@ gem 'highline', '~> 1.6.11' gem 'state_machine' gem 'redis-rails' -gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http' -gem "grit", :git => 'git://github.com/warpc/grit.git' #, :path => '~/Sites/code/grit' +gem 'grack', :git => 'git://github.com/rosa-abf/grack.git', :require => 'git_http' +gem 'grit', :git => 'git://github.com/warpc/grit.git' #, :path => '~/Sites/code/grit' gem 'charlock_holmes', '~> 0.6.9' #, :git => 'git://github.com/brianmario/charlock_holmes.git', :branch => 'bundle-icu' gem 'github-linguist', '~> 2.3.4', :require => 'linguist' gem 'diff-display', '~> 0.0.1' @@ -51,6 +51,7 @@ gem 'meta-tags', '~> 1.2.5', :require => 'meta_tags' gem "haml-rails", '~> 0.3.4' gem 'jquery-rails', '~> 2.0.2' gem 'ruby-haml-js', '~> 0.0.3' +gem 'friendly_id' gem 'rack-throttle' gem 'rest-client', '~> 1.6.6' diff --git a/Gemfile.lock b/Gemfile.lock index 4d08d44a6..7b1356941 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GIT - remote: git://github.com/rdblue/grack.git + remote: git://github.com/rosa-abf/grack.git revision: 020be3fef3fb308b9d214252522aa5945bf6584a specs: grack (0.2.0) @@ -129,6 +129,8 @@ GEM faraday (0.8.7) multipart-post (~> 1.1) ffi (1.0.11) + friendly_id (4.0.10.1) + activerecord (>= 3.0, < 4.0) fssm (0.2.10) gemoji (1.2.1) github-linguist (2.3.4) @@ -447,6 +449,7 @@ DEPENDENCIES devise (~> 2.2.3) diff-display (~> 0.0.1) factory_girl_rails (~> 4.0.0) + friendly_id gemoji (~> 1.2.1) github-linguist (~> 2.3.4) gollum (~> 2.1.3) diff --git a/app/assets/javascripts/angularjs/models/build_list.js.erb b/app/assets/javascripts/angularjs/models/build_list.js.erb index c1fa09f3b..020ca7ca9 100644 --- a/app/assets/javascripts/angularjs/models/build_list.js.erb +++ b/app/assets/javascripts/angularjs/models/build_list.js.erb @@ -24,6 +24,7 @@ var BuildList = function(atts, dictionary) { if (self.save_to_platform.personal) { self.save_to_repository_name += ' (' + self.build_for_platform.name + ')' } + self.save_to_repository_url = Routes.platform_repository_path(self.save_to_platform.name, self.save_to_repository.name); } if (self.project) { @@ -38,8 +39,6 @@ var BuildList = function(atts, dictionary) { self.project.name_with_owner = self.project.owner + '/' + self.project.name; } - if (self.save_to_platform_id) - self.save_to_repository_url = Routes.platform_repository_path(self.save_to_platform_id, self.save_to_repository_id); if (self.user) self.user.url = Routes.user_path(self.user.uname); self.url = Routes.build_list_path(self.id); diff --git a/app/controllers/platforms/key_pairs_controller.rb b/app/controllers/platforms/key_pairs_controller.rb index 4d9fb0ab0..8899c280c 100644 --- a/app/controllers/platforms/key_pairs_controller.rb +++ b/app/controllers/platforms/key_pairs_controller.rb @@ -1,4 +1,4 @@ -class Platforms::KeyPairsController < ApplicationController +class Platforms::KeyPairsController < Platforms::BaseController before_filter :authenticate_user! load_and_authorize_resource :platform, :only => [:index] diff --git a/app/models/platform.rb b/app/models/platform.rb index ad4660626..6b281b3a1 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -1,5 +1,8 @@ # -*- encoding : utf-8 -*- class Platform < ActiveRecord::Base + extend FriendlyId + friendly_id :name + include Modules::Models::FileStoreClean include Modules::Models::RegenerationStatus diff --git a/app/models/repository.rb b/app/models/repository.rb index ae2433142..e03452539 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,5 +1,8 @@ # -*- encoding : utf-8 -*- class Repository < ActiveRecord::Base + extend FriendlyId + friendly_id :name + LOCK_FILE_NAMES = {:sync => '.sync.lock', :repo => '.repo.lock'} SORT = {'base' => 1, 'main' => 2, 'contrib' => 3, 'non-free' => 4, 'restricted' => 5} diff --git a/config/routes.rb b/config/routes.rb index 0426da5fe..9efc3be31 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -152,7 +152,7 @@ Rosa::Application.routes.draw do end scope :module => 'platforms' do - resources :platforms do + resources :platforms, :constraints => {:id => Platform::NAME_PATTERN} do resources :private_users, :except => [:show, :destroy, :update] member do put :regenerate_metadata diff --git a/spec/controllers/platforms/key_pairs_controller_spec.rb b/spec/controllers/platforms/key_pairs_controller_spec.rb index cef278b35..bb21c11ac 100644 --- a/spec/controllers/platforms/key_pairs_controller_spec.rb +++ b/spec/controllers/platforms/key_pairs_controller_spec.rb @@ -78,7 +78,7 @@ describe Platforms::KeyPairsController do @create_params = { :platform_id => @platform, :key_pair => { - :repository_id => @repository, + :repository_id => @repository.id, :public => kp.public, :secret => kp.secret } diff --git a/spec/controllers/platforms/products_controller_spec.rb b/spec/controllers/platforms/products_controller_spec.rb index 4ba08c36c..c27fc6272 100644 --- a/spec/controllers/platforms/products_controller_spec.rb +++ b/spec/controllers/platforms/products_controller_spec.rb @@ -5,7 +5,7 @@ shared_examples_for 'admin user' do it 'should be able to create product' do lambda { post :create, @create_params }.should change{ Product.count }.by(1) - response.should redirect_to(platform_product_path( Product.last.platform.id, Product.last )) + response.should redirect_to(platform_product_path( Product.last.platform, Product.last )) end it 'should be able to update product' do @@ -31,7 +31,7 @@ describe Platforms::ProductsController do @product = FactoryGirl.create(:product, :platform => @platform) @project = FactoryGirl.create(:project) - params = {:platform_id => @platform.id, :src_project => @project.name_with_owner} + params = {:platform_id => @platform, :src_project => @project.name_with_owner} @create_params = params.merge({:product => {:name => 'pro', :time_living => 150}}) @update_params = params.merge({:product => {:name => 'pro2'}})