Upgrade rails, devise and other gems. Refactor controllers. Fix application.yml config - remove unused keys and setup correct values for tests. Add product build lists status_build callback auth. Allow platform and project unixname uppercase. Write tests and fix bugs for ProductBuildList controller. Fix all unresolved test problems. Refs #2262
This commit is contained in:
parent
74acc3b4a5
commit
02a813a474
15
Gemfile
15
Gemfile
|
@ -1,13 +1,13 @@
|
|||
source 'http://rubygems.org'
|
||||
|
||||
gem 'rails', '3.0.10' #, :git => 'git://github.com/rails/rails.git'
|
||||
gem 'rails', '3.0.11' #, :git => 'git://github.com/rails/rails.git'
|
||||
|
||||
gem 'pg', '~> 0.11.0'
|
||||
gem 'silent-postgres', '~> 0.1.1'
|
||||
|
||||
gem 'devise', '~> 1.4.8'
|
||||
gem 'omniauth', '~> 0.3.2'
|
||||
gem 'oa-openid', '~> 0.3.2', :require => 'omniauth/openid'
|
||||
gem 'devise', '~> 1.5.1'
|
||||
gem 'omniauth', '~> 1.0.1'
|
||||
gem 'omniauth-openid', '~> 1.0.1'
|
||||
gem 'cancan', '~> 1.6.7'
|
||||
#gem 'bitmask_attributes'
|
||||
|
||||
|
@ -27,14 +27,13 @@ gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
|
|||
gem "grit"
|
||||
gem 'whenever', :require => false
|
||||
gem 'delayed_job'
|
||||
gem 'whenever', :require => false
|
||||
|
||||
# XML-RPC support
|
||||
# gem 'actionwebservice' #, :git => 'git://github.com/ywen/actionwebservice.git'
|
||||
gem "rails-xmlrpc", :git => 'git://github.com/chipiga/rails-xmlrpc.git'
|
||||
gem "rails-xmlrpc", '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc.git'
|
||||
|
||||
group :production do
|
||||
gem "airbrake", :git => "git://github.com/airbrake/airbrake.git"
|
||||
gem "airbrake", '~> 3.0.5'
|
||||
# gem 'newrelic_rpm', '~> 3.1.1'
|
||||
end
|
||||
|
||||
|
@ -64,7 +63,7 @@ end
|
|||
group :development, :test do
|
||||
gem 'mysql2', '<= 0.2.9'
|
||||
gem 'rspec-rails', '~> 2.7.0'
|
||||
gem 'factory_girl_rails', '~> 1.3.0'
|
||||
gem 'factory_girl_rails', '~> 1.4.0'
|
||||
gem 'rr'
|
||||
end
|
||||
|
||||
|
|
168
Gemfile.lock
168
Gemfile.lock
|
@ -1,17 +1,3 @@
|
|||
GIT
|
||||
remote: git://github.com/airbrake/airbrake.git
|
||||
revision: 9a358aa5345d0143e21ea30802fe002c1105e0b3
|
||||
specs:
|
||||
airbrake (3.0.5)
|
||||
activesupport
|
||||
builder
|
||||
|
||||
GIT
|
||||
remote: git://github.com/chipiga/rails-xmlrpc.git
|
||||
revision: 3cf79e062c65447809209724a0cb8d1ea5af2e57
|
||||
specs:
|
||||
rails-xmlrpc (0.3.1)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rdblue/grack.git
|
||||
revision: 020be3fef3fb308b9d214252522aa5945bf6584a
|
||||
|
@ -21,15 +7,13 @@ GIT
|
|||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
XMLCanonicalizer (1.0.1)
|
||||
log4r (>= 1.0.4)
|
||||
abstract (1.0.0)
|
||||
actionmailer (3.0.10)
|
||||
actionpack (= 3.0.10)
|
||||
actionmailer (3.0.11)
|
||||
actionpack (= 3.0.11)
|
||||
mail (~> 2.2.19)
|
||||
actionpack (3.0.10)
|
||||
activemodel (= 3.0.10)
|
||||
activesupport (= 3.0.10)
|
||||
actionpack (3.0.11)
|
||||
activemodel (= 3.0.11)
|
||||
activesupport (= 3.0.11)
|
||||
builder (~> 2.1.2)
|
||||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.5.0)
|
||||
|
@ -37,20 +21,22 @@ GEM
|
|||
rack-mount (~> 0.6.14)
|
||||
rack-test (~> 0.5.7)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.10)
|
||||
activesupport (= 3.0.10)
|
||||
activemodel (3.0.11)
|
||||
activesupport (= 3.0.11)
|
||||
builder (~> 2.1.2)
|
||||
i18n (~> 0.5.0)
|
||||
activerecord (3.0.10)
|
||||
activemodel (= 3.0.10)
|
||||
activesupport (= 3.0.10)
|
||||
activerecord (3.0.11)
|
||||
activemodel (= 3.0.11)
|
||||
activesupport (= 3.0.11)
|
||||
arel (~> 2.0.10)
|
||||
tzinfo (~> 0.3.23)
|
||||
activeresource (3.0.10)
|
||||
activemodel (= 3.0.10)
|
||||
activesupport (= 3.0.10)
|
||||
activesupport (3.0.10)
|
||||
addressable (2.2.6)
|
||||
activeresource (3.0.11)
|
||||
activemodel (= 3.0.11)
|
||||
activesupport (= 3.0.11)
|
||||
activesupport (3.0.11)
|
||||
airbrake (3.0.5)
|
||||
activesupport
|
||||
builder
|
||||
ancestry (1.2.4)
|
||||
activerecord (>= 2.2.2)
|
||||
arel (2.0.10)
|
||||
|
@ -66,10 +52,10 @@ GEM
|
|||
capistrano-ext (1.2.1)
|
||||
capistrano (>= 1.0.0)
|
||||
capistrano_colors (0.5.5)
|
||||
chronic (0.6.5)
|
||||
chronic (0.6.6)
|
||||
chunky_png (1.2.5)
|
||||
cocaine (0.2.0)
|
||||
columnize (0.3.4)
|
||||
columnize (0.3.5)
|
||||
compass (0.11.5)
|
||||
chunky_png (~> 1.2)
|
||||
fssm (>= 0.2.7)
|
||||
|
@ -78,22 +64,18 @@ GEM
|
|||
delayed_job (2.1.4)
|
||||
activesupport (~> 3.0)
|
||||
daemons
|
||||
devise (1.4.9)
|
||||
devise (1.5.1)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
orm_adapter (~> 0.0.3)
|
||||
warden (~> 1.0.3)
|
||||
warden (~> 1.1)
|
||||
diff-lcs (1.1.3)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
factory_girl (2.2.0)
|
||||
factory_girl (2.3.1)
|
||||
activesupport
|
||||
factory_girl_rails (1.3.0)
|
||||
factory_girl (~> 2.2.0)
|
||||
factory_girl_rails (1.4.0)
|
||||
factory_girl (~> 2.3.0)
|
||||
railties (>= 3.0.0)
|
||||
faraday (0.7.5)
|
||||
addressable (~> 2.2.6)
|
||||
multipart-post (~> 1.1.3)
|
||||
rack (>= 1.1.0, < 2)
|
||||
fssm (0.2.7)
|
||||
grit (2.4.1)
|
||||
diff-lcs (~> 1.1)
|
||||
|
@ -104,7 +86,8 @@ GEM
|
|||
activesupport (~> 3.0)
|
||||
haml (~> 3.0)
|
||||
railties (~> 3.0)
|
||||
highline (1.6.5)
|
||||
hashie (1.2.0)
|
||||
highline (1.6.8)
|
||||
hirb (0.5.0)
|
||||
hpricot (0.8.4)
|
||||
i18n (0.5.0)
|
||||
|
@ -113,9 +96,6 @@ GEM
|
|||
json (1.6.1)
|
||||
linecache (0.46)
|
||||
rbx-require-relative (> 0.0.4)
|
||||
log4r (1.1.9)
|
||||
macaddr (1.5.0)
|
||||
systemu (>= 2.4.0)
|
||||
mail (2.2.19)
|
||||
activesupport (>= 2.3.6)
|
||||
i18n (>= 0.4.0)
|
||||
|
@ -124,11 +104,7 @@ GEM
|
|||
meta-tags (1.2.4)
|
||||
actionpack
|
||||
mime-types (1.17.2)
|
||||
multi_json (1.0.3)
|
||||
multi_xml (0.4.1)
|
||||
multipart-post (1.1.3)
|
||||
mysql2 (0.2.9)
|
||||
net-ldap (0.2.2)
|
||||
net-scp (1.0.4)
|
||||
net-ssh (>= 1.99.1)
|
||||
net-sftp (2.0.5)
|
||||
|
@ -136,46 +112,12 @@ GEM
|
|||
net-ssh (2.2.1)
|
||||
net-ssh-gateway (1.1.0)
|
||||
net-ssh (>= 1.99.1)
|
||||
nokogiri (1.5.0)
|
||||
oa-basic (0.3.2)
|
||||
oa-core (= 0.3.2)
|
||||
rest-client (~> 1.6.0)
|
||||
oa-core (0.3.2)
|
||||
oa-enterprise (0.3.2)
|
||||
XMLCanonicalizer (~> 1.0.1)
|
||||
addressable (~> 2.2.6)
|
||||
net-ldap (~> 0.2.2)
|
||||
nokogiri (~> 1.5.0)
|
||||
oa-core (= 0.3.2)
|
||||
pyu-ruby-sasl (~> 0.0.3.1)
|
||||
rubyntlm (~> 0.1.1)
|
||||
uuid
|
||||
oa-more (0.3.2)
|
||||
multi_json (~> 1.0.0)
|
||||
oa-core (= 0.3.2)
|
||||
rest-client (~> 1.6.0)
|
||||
oa-oauth (0.3.2)
|
||||
faraday (~> 0.7.3)
|
||||
multi_json (~> 1.0.0)
|
||||
multi_xml (~> 0.4.0)
|
||||
oa-core (= 0.3.2)
|
||||
oauth (~> 0.4.0)
|
||||
oauth2 (~> 0.5.0)
|
||||
oa-openid (0.3.2)
|
||||
oa-core (= 0.3.2)
|
||||
omniauth (1.0.1)
|
||||
hashie (~> 1.2)
|
||||
rack
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
ruby-openid-apps-discovery (~> 1.2.0)
|
||||
oauth (0.4.5)
|
||||
oauth2 (0.5.1)
|
||||
faraday (~> 0.7.4)
|
||||
multi_json (~> 1.0.3)
|
||||
omniauth (0.3.2)
|
||||
oa-basic (= 0.3.2)
|
||||
oa-core (= 0.3.2)
|
||||
oa-enterprise (= 0.3.2)
|
||||
oa-more (= 0.3.2)
|
||||
oa-oauth (= 0.3.2)
|
||||
oa-openid (= 0.3.2)
|
||||
orm_adapter (0.0.5)
|
||||
paperclip (2.4.5)
|
||||
activerecord (>= 2.3.0)
|
||||
|
@ -184,7 +126,6 @@ GEM
|
|||
mime-types
|
||||
pg (0.11.0)
|
||||
polyglot (0.3.3)
|
||||
pyu-ruby-sasl (0.0.3.3)
|
||||
rack (1.2.4)
|
||||
rack-mount (0.6.14)
|
||||
rack (>= 1.0.0)
|
||||
|
@ -193,19 +134,20 @@ GEM
|
|||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.5.7)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.10)
|
||||
actionmailer (= 3.0.10)
|
||||
actionpack (= 3.0.10)
|
||||
activerecord (= 3.0.10)
|
||||
activeresource (= 3.0.10)
|
||||
activesupport (= 3.0.10)
|
||||
rails (3.0.11)
|
||||
actionmailer (= 3.0.11)
|
||||
actionpack (= 3.0.11)
|
||||
activerecord (= 3.0.11)
|
||||
activeresource (= 3.0.11)
|
||||
activesupport (= 3.0.11)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.0.10)
|
||||
railties (= 3.0.11)
|
||||
rails-xmlrpc (0.3.6)
|
||||
rails3-generators (0.17.4)
|
||||
railties (>= 3.0.0)
|
||||
railties (3.0.10)
|
||||
actionpack (= 3.0.10)
|
||||
activesupport (= 3.0.10)
|
||||
railties (3.0.11)
|
||||
actionpack (= 3.0.11)
|
||||
activesupport (= 3.0.11)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (~> 0.14.4)
|
||||
|
@ -213,8 +155,6 @@ GEM
|
|||
rbx-require-relative (0.0.5)
|
||||
rdoc (3.11)
|
||||
json (~> 1.4)
|
||||
rest-client (1.6.7)
|
||||
mime-types (>= 1.16)
|
||||
rr (1.0.4)
|
||||
rspec (2.7.0)
|
||||
rspec-core (~> 2.7.0)
|
||||
|
@ -235,25 +175,19 @@ GEM
|
|||
ruby-debug-base (0.10.4)
|
||||
linecache (>= 0.3)
|
||||
ruby-openid (2.1.8)
|
||||
ruby-openid-apps-discovery (1.2.0)
|
||||
ruby-openid (>= 2.1.7)
|
||||
ruby_parser (2.3.1)
|
||||
sexp_processor (~> 3.0)
|
||||
rubyntlm (0.1.1)
|
||||
russian (0.6.0)
|
||||
i18n (>= 0.5.0)
|
||||
sass (3.1.10)
|
||||
sexp_processor (3.0.7)
|
||||
sexp_processor (3.0.8)
|
||||
silent-postgres (0.1.1)
|
||||
systemu (2.4.1)
|
||||
thor (0.14.6)
|
||||
treetop (1.4.10)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.31)
|
||||
uuid (2.3.4)
|
||||
macaddr (~> 1.0)
|
||||
warden (1.0.6)
|
||||
warden (1.1.0)
|
||||
rack (>= 1.0)
|
||||
web-app-theme (0.7.0)
|
||||
whenever (0.7.0)
|
||||
|
@ -266,7 +200,7 @@ PLATFORMS
|
|||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
airbrake!
|
||||
airbrake (~> 3.0.5)
|
||||
ancestry (~> 1.2.4)
|
||||
cancan (~> 1.6.7)
|
||||
capistrano
|
||||
|
@ -274,8 +208,8 @@ DEPENDENCIES
|
|||
capistrano_colors
|
||||
compass (~> 0.11.5)
|
||||
delayed_job
|
||||
devise (~> 1.4.8)
|
||||
factory_girl_rails (~> 1.3.0)
|
||||
devise (~> 1.5.1)
|
||||
factory_girl_rails (~> 1.4.0)
|
||||
grack!
|
||||
grit
|
||||
haml-rails (~> 0.3.4)
|
||||
|
@ -284,12 +218,12 @@ DEPENDENCIES
|
|||
jammit
|
||||
meta-tags (~> 1.2.4)
|
||||
mysql2 (<= 0.2.9)
|
||||
oa-openid (~> 0.3.2)
|
||||
omniauth (~> 0.3.2)
|
||||
omniauth (~> 1.0.1)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
paperclip (~> 2.3)
|
||||
pg (~> 0.11.0)
|
||||
rails (= 3.0.10)
|
||||
rails-xmlrpc!
|
||||
rails (= 3.0.11)
|
||||
rails-xmlrpc (~> 0.3.6)
|
||||
rails3-generators
|
||||
rr
|
||||
rspec-rails (~> 2.7.0)
|
||||
|
|
|
@ -26,16 +26,4 @@ class ApplicationController < ActionController::Base
|
|||
"application"
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate_build_service!
|
||||
if request.remote_ip != APP_CONFIG['build_service_ip']
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate_product_builder!
|
||||
if request.remote_ip != APP_CONFIG['product_builder_ip']
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -133,4 +133,9 @@ class BuildListsController < ApplicationController
|
|||
@build_list = BuildList.find_by_bs_id!(params[:id])
|
||||
end
|
||||
|
||||
def authenticate_build_service!
|
||||
if request.remote_ip != APP_CONFIG['build_server_ip']
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
class ProductBuildListsController < ApplicationController
|
||||
before_filter :authenticate_user!, :except => [:status_build]
|
||||
load_and_authorize_resource :platform, :only => [:create]
|
||||
load_and_authorize_resource :product, :through => :platform, :only => [:create]
|
||||
load_and_authorize_resource :product_build_list, :through => :product, :only => [:create]
|
||||
|
||||
before_filter :authenticate_product_builder!, :only => [:status_build]
|
||||
before_filter :find_product_build_list, :only => [:status_build]
|
||||
before_filter :find_product, :except => [:status_build]
|
||||
before_filter :find_platform, :except => [:status_build]
|
||||
|
||||
load_and_authorize_resource :platform
|
||||
load_and_authorize_resource :product, :through => :platform
|
||||
load_and_authorize_resource :product_build_list, :through => :product
|
||||
|
||||
# def index
|
||||
# end
|
||||
|
||||
def create
|
||||
@product.product_build_lists.create! :base_url => "http://#{request.host_with_port}", :notified_at => Time.current
|
||||
|
@ -26,15 +22,13 @@ class ProductBuildListsController < ApplicationController
|
|||
|
||||
protected
|
||||
|
||||
def find_product_build_list
|
||||
@product_build_list = ProductBuildList.find params[:id]
|
||||
end
|
||||
def find_product_build_list
|
||||
@product_build_list = ProductBuildList.find params[:id]
|
||||
end
|
||||
|
||||
def find_product
|
||||
@product = Product.find params[:product_id]
|
||||
end
|
||||
|
||||
def find_platform
|
||||
@platform = Platform.find params[:platform_id]
|
||||
def authenticate_product_builder!
|
||||
if request.remote_ip != APP_CONFIG['product_builder_ip']
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class Platform < ActiveRecord::Base
|
|||
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
|
||||
|
||||
validates :name, :presence => true, :uniqueness => true
|
||||
validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-z0-9_]+$/ }
|
||||
validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }
|
||||
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
|
||||
|
||||
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
|
||||
|
|
|
@ -15,7 +15,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
|
||||
|
||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true
|
||||
validates :unixname, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-z0-9_\-\+\.]+$/ }
|
||||
validates :unixname, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ }
|
||||
validates :owner, :presence => true
|
||||
# validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?}
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ describe CollaboratorsController do
|
|||
context 'for guest' do
|
||||
it 'should not be able to perform index action' do
|
||||
get :index, :project_id => @project.id
|
||||
response.should redirect_to(forbidden_path)
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
|
||||
it 'should not be able to perform update action' do
|
||||
get :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(forbidden_path)
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -31,12 +31,12 @@ describe CollaboratorsController do
|
|||
end
|
||||
|
||||
it 'should be able to perform update action' do
|
||||
get :update, {:project_id => @project.id}.merge(@update_params)
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(project_path(@project))
|
||||
end
|
||||
|
||||
it 'should set flash notice on update success' do
|
||||
get :update, {:project_id => @project.id}.merge(@update_params)
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
flash[:notice].should_not be_blank
|
||||
end
|
||||
end
|
||||
|
@ -56,12 +56,12 @@ describe CollaboratorsController do
|
|||
end
|
||||
|
||||
it 'should be able to perform update action' do
|
||||
get :update, {:project_id => @project.id}.merge(@update_params)
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(project_path(@project))
|
||||
end
|
||||
|
||||
it 'should set flash notice on update success' do
|
||||
get :update, {:project_id => @project.id}.merge(@update_params)
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
flash[:notice].should_not be_blank
|
||||
end
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ describe CollaboratorsController do
|
|||
end
|
||||
|
||||
it 'should not be able to perform update action' do
|
||||
get :update, {:project_id => @project.id}.merge(@update_params)
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(project_path(@project))
|
||||
end
|
||||
end
|
||||
|
@ -101,7 +101,7 @@ describe CollaboratorsController do
|
|||
end
|
||||
|
||||
it 'should not be able to perform update action' do
|
||||
get :update, {:project_id => @project.id}.merge(@update_params)
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(project_path(@project))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
# require 'spec_helper'
|
||||
#
|
||||
# describe DownloadController do
|
||||
#
|
||||
# end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DownloadsController do
|
||||
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
#describe GitController do
|
||||
#
|
||||
#end
|
|
@ -1,157 +1,61 @@
|
|||
require 'spec_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
describe ProductBuildListsController do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# ProductBuildList. As you add validations to ProductBuildList, be sure to
|
||||
# update the return value of this method accordingly.
|
||||
def valid_attributes
|
||||
{}
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all product_build_lists as @product_build_lists" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
get :index
|
||||
assigns(:product_build_lists).should eq([product_build_list])
|
||||
context 'crud' do
|
||||
def valid_attributes
|
||||
{:product_id => product.id, :platform_id => product.platform_id}
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
it "assigns the requested product_build_list as @product_build_list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
get :show, :id => product_build_list.id
|
||||
assigns(:product_build_list).should eq(product_build_list)
|
||||
let(:product) { Factory(:product) }
|
||||
|
||||
context 'for guest' do
|
||||
it 'should not be able to perform create action' do
|
||||
post :create, valid_attributes
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "assigns a new product_build_list as @product_build_list" do
|
||||
get :new
|
||||
assigns(:product_build_list).should be_a_new(ProductBuildList)
|
||||
context 'for user' do
|
||||
before(:each) { set_session_for Factory(:user) }
|
||||
|
||||
it 'should not be able to perform create action' do
|
||||
post :create, valid_attributes
|
||||
response.should redirect_to(forbidden_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET edit" do
|
||||
it "assigns the requested product_build_list as @product_build_list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
get :edit, :id => product_build_list.id
|
||||
assigns(:product_build_list).should eq(product_build_list)
|
||||
end
|
||||
end
|
||||
context 'for admin' do
|
||||
before(:each) { set_session_for Factory(:admin) }
|
||||
|
||||
describe "POST create" do
|
||||
describe "with valid params" do
|
||||
it "creates a new ProductBuildList" do
|
||||
expect {
|
||||
post :create, :product_build_list => valid_attributes
|
||||
post :create, valid_attributes
|
||||
}.to change(ProductBuildList, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created product_build_list as @product_build_list" do
|
||||
post :create, :product_build_list => valid_attributes
|
||||
assigns(:product_build_list).should be_a(ProductBuildList)
|
||||
assigns(:product_build_list).should be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created product_build_list" do
|
||||
post :create, :product_build_list => valid_attributes
|
||||
response.should redirect_to(ProductBuildList.last)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns a newly created but unsaved product_build_list as @product_build_list" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ProductBuildList.any_instance.stub(:save).and_return(false)
|
||||
post :create, :product_build_list => {}
|
||||
assigns(:product_build_list).should be_a_new(ProductBuildList)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ProductBuildList.any_instance.stub(:save).and_return(false)
|
||||
post :create, :product_build_list => {}
|
||||
response.should render_template("new")
|
||||
it "redirects to the product" do
|
||||
post :create, valid_attributes
|
||||
response.should redirect_to([product.platform, product])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT update" do
|
||||
describe "with valid params" do
|
||||
it "updates the requested product_build_list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
# Assuming there are no other product_build_lists in the database, this
|
||||
# specifies that the ProductBuildList created on the previous line
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
ProductBuildList.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
|
||||
put :update, :id => product_build_list.id, :product_build_list => {'these' => 'params'}
|
||||
end
|
||||
context 'callbacks' do
|
||||
let(:product_build_list) { Factory(:product_build_list) }
|
||||
|
||||
it "assigns the requested product_build_list as @product_build_list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
put :update, :id => product_build_list.id, :product_build_list => valid_attributes
|
||||
assigns(:product_build_list).should eq(product_build_list)
|
||||
end
|
||||
|
||||
it "redirects to the product_build_list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
put :update, :id => product_build_list.id, :product_build_list => valid_attributes
|
||||
response.should redirect_to(product_build_list)
|
||||
end
|
||||
def do_get
|
||||
get :status_build, :id => product_build_list.id, :status => ProductBuildList::BUILD_FAILED
|
||||
product_build_list.reload
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns the product_build_list as @product_build_list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ProductBuildList.any_instance.stub(:save).and_return(false)
|
||||
put :update, :id => product_build_list.id, :product_build_list => {}
|
||||
assigns(:product_build_list).should eq(product_build_list)
|
||||
end
|
||||
it do
|
||||
expect { do_get }.to change(product_build_list, :status).to(ProductBuildList::BUILD_FAILED)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ProductBuildList.any_instance.stub(:save).and_return(false)
|
||||
put :update, :id => product_build_list.id, :product_build_list => {}
|
||||
response.should render_template("edit")
|
||||
end
|
||||
it do
|
||||
do_get
|
||||
response.should be_success
|
||||
response.body.should be_blank
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE destroy" do
|
||||
it "destroys the requested product_build_list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, :id => product_build_list.id
|
||||
}.to change(ProductBuildList, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the product_build_lists list" do
|
||||
product_build_list = ProductBuildList.create! valid_attributes
|
||||
delete :destroy, :id => product_build_list.id
|
||||
response.should redirect_to(product_build_lists_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,13 +20,13 @@ describe ProjectsController do
|
|||
|
||||
context 'for guest' do
|
||||
it 'should not be able to perform index action' do
|
||||
get :index, :id => @project.id
|
||||
response.should redirect_to(forbidden_path)
|
||||
get :index
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
|
||||
it 'should not be able to perform update action' do
|
||||
get :update, {:id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(forbidden_path)
|
||||
put :update, {:id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe ProjectsController do
|
|||
end
|
||||
|
||||
it 'should be able to perform index action' do
|
||||
get :index, :id => @project.id
|
||||
get :index
|
||||
response.should render_template(:index)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Factory.define(:product_build_list) do |p|
|
||||
p.association :product, :factory => :product
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
Factory.define(:product) do |p|
|
||||
p.name { Factory.next(:string) }
|
||||
p.association :platform, :factory => :platform
|
||||
end
|
|
@ -118,7 +118,7 @@ describe CanCan do
|
|||
|
||||
context 'with read rights' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'read')
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
end
|
||||
|
||||
it 'should be able to read project' do
|
||||
|
@ -132,7 +132,7 @@ describe CanCan do
|
|||
|
||||
context 'with write rights' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'write')
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'writer')
|
||||
end
|
||||
|
||||
[:read, :update, :process_build, :build].each do |action|
|
||||
|
@ -189,7 +189,7 @@ describe CanCan do
|
|||
|
||||
context 'with read rights' do
|
||||
before(:each) do
|
||||
@platform.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'read')
|
||||
@platform.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
end
|
||||
|
||||
it "should be able to read platform" do
|
||||
|
@ -217,7 +217,7 @@ describe CanCan do
|
|||
|
||||
context 'with read rights' do
|
||||
before(:each) do
|
||||
@repository.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'read')
|
||||
@repository.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
end
|
||||
|
||||
it "should be able to read repository" do
|
||||
|
@ -229,7 +229,7 @@ describe CanCan do
|
|||
context 'build list relations' do
|
||||
before(:each) do
|
||||
@project = Factory(:project)
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'read')
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
@build_list = Factory(:build_list, :project => @project)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe ProductBuildListsController do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
get("/product_build_lists").should route_to("product_build_lists#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
get("/product_build_lists/new").should route_to("product_build_lists#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
get("/product_build_lists/1").should route_to("product_build_lists#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
get("/product_build_lists/1/edit").should route_to("product_build_lists#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
post("/product_build_lists").should route_to("product_build_lists#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
put("/product_build_lists/1").should route_to("product_build_lists#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
delete("/product_build_lists/1").should route_to("product_build_lists#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
# require "spec_helper"
|
||||
#
|
||||
# describe ProductBuildListsController do
|
||||
# describe "routing" do
|
||||
#
|
||||
# it "routes to #index" do
|
||||
# get("/product_build_lists").should route_to("product_build_lists#index")
|
||||
# end
|
||||
#
|
||||
# it "routes to #new" do
|
||||
# get("/product_build_lists/new").should route_to("product_build_lists#new")
|
||||
# end
|
||||
#
|
||||
# it "routes to #show" do
|
||||
# get("/product_build_lists/1").should route_to("product_build_lists#show", :id => "1")
|
||||
# end
|
||||
#
|
||||
# it "routes to #edit" do
|
||||
# get("/product_build_lists/1/edit").should route_to("product_build_lists#edit", :id => "1")
|
||||
# end
|
||||
#
|
||||
# it "routes to #create" do
|
||||
# post("/product_build_lists").should route_to("product_build_lists#create")
|
||||
# end
|
||||
#
|
||||
# it "routes to #update" do
|
||||
# put("/product_build_lists/1").should route_to("product_build_lists#update", :id => "1")
|
||||
# end
|
||||
#
|
||||
# it "routes to #destroy" do
|
||||
# delete("/product_build_lists/1").should route_to("product_build_lists#destroy", :id => "1")
|
||||
# end
|
||||
#
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -24,8 +24,6 @@ RSpec.configure do |config|
|
|||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
include Devise::TestHelpers
|
||||
end
|
||||
|
||||
def set_session_for(user=nil)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
end
|
Loading…
Reference in New Issue