Upgrade gems. Fix and refactor some specs. Fix deprecation warnings. Add capistrano task to dump remote db. Refs #263

This commit is contained in:
Pavel Chipiga 2012-08-15 16:52:32 +03:00
parent 8c07e5a516
commit 0ff8f92b62
28 changed files with 314 additions and 256 deletions

12
Gemfile
View File

@ -1,6 +1,6 @@
source 'http://rubygems.org'
gem 'rails', '3.2.7' #, :git => 'git://github.com/rails/rails.git'
gem 'rails', '3.2.8' #, :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'
@ -25,13 +25,13 @@ gem 'state_machine'
# gem 'rugged', '~> 0.16.0'
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 'charlock_holmes', '~> 0.6.8' #, :git => 'git://github.com/brianmario/charlock_holmes.git', :branch => 'bundle-icu'
gem 'charlock_holmes', '~> 0.6.9' #, :git => 'git://github.com/brianmario/charlock_holmes.git', :branch => 'bundle-icu'
# gem 'ruby-filemagic', '~> 0.4.2', :require => 'filemagic/ext'
gem 'github-linguist', '~> 2.1.2', :require => 'linguist'
gem 'github-linguist', '~> 2.2.1', :require => 'linguist'
gem 'diff-display', '~> 0.0.1'
# Wiki
gem "gollum", :git => 'git://github.com/github/gollum.git'
gem "gollum", '~> 2.1.3'
gem "redcarpet", "1.17.2"
gem 'creole'
gem 'rdiscount'
@ -58,7 +58,7 @@ group :assets do
gem 'coffee-rails', '~> 3.2.2'
gem 'compass-rails', '~> 1.0.3'
gem 'uglifier', '~> 1.2.4'
gem 'therubyracer', '~> 0.10.1', :platforms => [:mri, :rbx]
gem 'therubyracer', '~> 0.10.2', :platforms => [:mri, :rbx]
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
end
@ -81,7 +81,7 @@ end
group :test do
gem 'rspec-rails', '~> 2.11.0', :group => 'development'
gem 'factory_girl_rails', '~> 3.6.0'
gem 'factory_girl_rails', '~> 4.0.0'
gem 'rr', '~> 1.0.4'
gem 'shoulda'
end

View File

@ -6,23 +6,6 @@ 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
@ -42,12 +25,12 @@ GEM
remote: http://rubygems.org/
specs:
RedCloth (4.2.9)
actionmailer (3.2.7)
actionpack (= 3.2.7)
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
@ -55,18 +38,18 @@ GEM
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.7)
activesupport (= 3.2.7)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
activesupport (3.2.7)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
airbrake (3.1.2)
@ -92,9 +75,9 @@ GEM
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capistrano_colors (0.5.5)
charlock_holmes (0.6.8)
charlock_holmes (0.6.9)
chronic (0.6.7)
chunky_png (1.2.5)
chunky_png (1.2.6)
cocaine (0.2.1)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@ -125,21 +108,33 @@ GEM
execjs (1.4.0)
multi_json (~> 1.0)
expression_parser (0.9.0)
factory_girl (3.6.0)
factory_girl (4.0.0)
activesupport (>= 3.0.0)
factory_girl_rails (3.6.0)
factory_girl (~> 3.6.0)
factory_girl_rails (4.0.0)
factory_girl (~> 4.0.0)
railties (>= 3.0.0)
ffi (1.0.11)
fssm (0.2.9)
github-linguist (2.1.2)
github-linguist (2.2.1)
charlock_holmes (~> 0.6.6)
escape_utils (~> 0.2.3)
mime-types (~> 1.18)
pygments.rb (>= 0.2.13)
github-markdown (0.5.0)
github-markup (0.7.4)
haml (3.1.6)
gollum (2.1.3)
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)
haml (3.1.7)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
@ -150,7 +145,7 @@ GEM
hike (1.2.1)
hirb (0.7.0)
i18n (0.6.0)
jbuilder (0.4.0)
jbuilder (0.4.3)
activesupport (>= 3.0.0)
blankslate (>= 2.1.2.4)
journey (1.0.4)
@ -223,14 +218,14 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.7)
actionmailer (= 3.2.7)
actionpack (= 3.2.7)
activerecord (= 3.2.7)
activeresource (= 3.2.7)
activesupport (= 3.2.7)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.7)
railties (= 3.2.8)
rails-backbone (0.7.2)
coffee-script (~> 2.2.0)
ejs (~> 1.0.0)
@ -239,9 +234,9 @@ GEM
railties (>= 3.0.0)
rails3-jquery-autocomplete (1.0.7)
rails (~> 3.0)
railties (3.2.7)
actionpack (= 3.2.7)
activesupport (= 3.2.7)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@ -253,7 +248,7 @@ GEM
json (~> 1.4)
redcarpet (1.17.2)
redis (3.0.1)
redis-namespace (1.2.0)
redis-namespace (1.2.1)
redis (~> 3.0.0)
redisk (0.2.2)
redis (>= 0.1.1)
@ -277,7 +272,7 @@ GEM
rspec-core (2.11.1)
rspec-expectations (2.11.2)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.1)
rspec-mocks (2.11.2)
rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
@ -296,7 +291,7 @@ GEM
capistrano (>= 2.0.0)
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
sass (3.1.20)
sass (3.2.0)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
@ -324,19 +319,19 @@ GEM
state_machine (1.1.2)
stringex (1.4.0)
systemu (2.5.2)
therubyracer (0.10.1)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
thin (1.4.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.15.4)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.6)
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
unicorn (4.3.1)
@ -370,15 +365,15 @@ DEPENDENCIES
cape
capistrano
capistrano_colors
charlock_holmes (~> 0.6.8)
charlock_holmes (~> 0.6.9)
coffee-rails (~> 3.2.2)
compass-rails (~> 1.0.3)
creole
devise (~> 2.1.2)
diff-display (~> 0.0.1)
factory_girl_rails (~> 3.6.0)
github-linguist (~> 2.1.2)
gollum!
factory_girl_rails (~> 4.0.0)
github-linguist (~> 2.2.1)
gollum (~> 2.1.3)
grack!
grit!
haml-rails (~> 0.3.4)
@ -394,7 +389,7 @@ DEPENDENCIES
paperclip (~> 3.1.4)
perform_later (~> 1.3.0)
pg (~> 0.14.0)
rails (= 3.2.7)
rails (= 3.2.8)
rails-backbone (~> 0.7.2)
rails3-generators
rails3-jquery-autocomplete (~> 1.0.7)
@ -413,7 +408,7 @@ DEPENDENCIES
shotgun
shoulda
state_machine
therubyracer (~> 0.10.1)
therubyracer (~> 0.10.2)
therubyrhino (~> 1.73.1)
trinidad (~> 1.0.2)
uglifier (~> 1.2.4)

View File

@ -23,7 +23,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
end
def destroy
if @product_build_list.destroy
if @product_build_list.destroy
flash[:notice] = t('flash.product_build_list.delete')
else
flash[:error] = t('flash.product_build_list.delete_error')

View File

@ -4,7 +4,7 @@ class Projects::CommentsController < Projects::BaseController
load_and_authorize_resource :project
before_filter :find_commentable
before_filter :find_or_build_comment
load_and_authorize_resource
load_and_authorize_resource #:through => :commentable
include CommentsHelper

View File

@ -119,7 +119,7 @@ class Ability
cannot :manage, Issue, :project => {:has_issues => false} # switch off issues
can(:create, Comment) {|comment| can? :read, comment.project}
can(:update, Comment) {|comment| comment.user_id == user.id or local_admin?(comment.project || comment.commentable.project)}
can(:update, Comment) {|comment| comment.user == user or comment.project.owner == user or local_admin?(comment.project)}
cannot :manage, Comment, :commentable_type => 'Issue', :commentable => {:project => {:has_issues => false}} # switch off issues
end

View File

@ -45,8 +45,8 @@ class MassBuild < ActiveRecord::Base
end
def cancel_all
self.update_attribute(:stop_build, true)
self.build_lists.find_each(:batch_size => 100) do |bl|
self.stop_build = true; save(:validate => false)
build_lists.find_each(:batch_size => 100) do |bl|
bl.cancel
end
end

View File

@ -131,11 +131,11 @@ class Platform < ActiveRecord::Base
end
def change_visibility
if !self.hidden?
self.update_attribute(:visibility, 'hidden')
if !hidden?
update_attributes(:visibility => 'hidden')
remove_symlink_directory
else
self.update_attribute(:visibility, 'open')
update_attributes(:visibility => 'open')
symlink_directory
end
end

View File

@ -34,7 +34,7 @@ class Subscribe < ActiveRecord::Base
def self.set_subscribe_to_commit(options, status)
if subscribe = Subscribe.where(options).first
subscribe.update_attribute(:status, status)
subscribe.update_attributes(:status => status)
else
Subscribe.create(options.merge(:status => status))
end

View File

@ -101,3 +101,32 @@ namespace :rake_tasks do
mirror_rake_tasks 'db:seeds'
end
end
namespace :update do
desc "Copy remote production shared files to localhost"
task :shared do
run_locally "rsync --recursive --times --rsh=ssh --compress --human-readable --progress #{user}@#{domain}:#{shared_path}/shared_contents/uploads public/uploads"
end
desc "Dump remote production postgresql database, rsync to localhost"
task :postgresql do
get("#{current_path}/config/database.yml", "tmp/database.yml")
remote_settings = YAML::load_file("tmp/database.yml")[rails_env]
local_settings = YAML::load_file("config/database.yml")["development"]
run "export PGPASSWORD=#{remote_settings["password"]} && pg_dump --host=#{remote_settings["host"]} --port=#{remote_settings["port"]} --username #{remote_settings["username"]} --file #{current_path}/tmp/#{remote_settings["database"]}_dump -Fc #{remote_settings["database"]}"
run_locally "rsync --recursive --times --rsh=ssh --compress --human-readable --progress #{user}@#{domain}:#{current_path}/tmp/#{remote_settings["database"]}_dump tmp/"
run_locally "dropdb -U #{local_settings["username"]} --host=#{local_settings["host"]} --port=#{local_settings["port"]} #{local_settings["database"]}"
run_locally "createdb -U #{local_settings["username"]} --host=#{local_settings["host"]} --port=#{local_settings["port"]} -T template0 #{local_settings["database"]}"
run_locally "pg_restore -U #{local_settings["username"]} --host=#{local_settings["host"]} --port=#{local_settings["port"]} -d #{local_settings["database"]} tmp/#{remote_settings["database"]}_dump"
end
desc "Dump all remote data to localhost"
task :all do
# update.shared
update.postgresql
end
end

View File

@ -5,7 +5,7 @@ class AddProjectToComment < ActiveRecord::Migration
Subscribe.reset_column_information
Comment.where(:commentable_type => 'Grit::Commit').destroy_all
Comment.where(:commentable_type => 'Issue').each do |comment|
comment.update_attribute(:project_id, comment.commentable.project)
comment.update_column(:project_id, comment.commentable.project.id)
end
end

View File

@ -53,8 +53,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
create_table "arches", :force => true do |t|
t.string "name", :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 "arches", ["name"], :name => "index_arches_on_name", :unique => true
@ -63,8 +63,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.integer "user_id"
t.string "provider"
t.string "uid"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true
@ -75,8 +75,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.integer "level"
t.integer "status"
t.integer "build_list_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "version"
end
@ -169,12 +169,10 @@ ActiveRecord::Schema.define(:version => 20120730214052) 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", :null => false
t.datetime "updated_at", :null => false
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"
@ -255,7 +253,7 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "owner_type"
t.string "visibility", :default => "open", :null => false
t.string "platform_type", :default => "main", :null => false
t.string "distrib_type", :null => false
t.string "distrib_type"
end
add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false
@ -264,16 +262,16 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.integer "platform_id"
t.string "login"
t.string "password"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
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", :null => false
t.datetime "updated_at", :null => false
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"
@ -281,8 +279,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
create_table "products", :force => true do |t|
t.string "name", :null => false
t.integer "platform_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "build_script"
t.text "counter"
t.text "ks"
@ -301,8 +299,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "name"
t.string "version"
t.datetime "file_mtime"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "platform_id"
end
@ -311,8 +309,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
create_table "project_to_repositories", :force => true do |t|
t.integer "project_id"
t.integer "repository_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "projects", :force => true do |t|
@ -344,8 +342,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "token"
t.boolean "approved", :default => false
t.boolean "rejected", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "interest"
t.text "more"
end
@ -358,16 +356,16 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "actor_type"
t.integer "target_id"
t.string "target_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
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", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name", :null => false
end
@ -378,8 +376,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.boolean "new_comment_reply", :default => true
t.boolean "new_issue", :default => true
t.boolean "issue_assign", :default => true
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
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
@ -388,8 +386,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
create_table "subscribes", :force => true do |t|
t.string "subscribeable_type"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
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
@ -404,10 +402,14 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.datetime "remember_created_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "ssh_key"
t.string "uname"
t.string "role"
t.string "language", :default => "en"
t.integer "own_projects_count", :default => 0, :null => false
t.string "language", :default => "en"
t.integer "own_projects_count", :default => 0, :null => false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.text "professional_experience"
t.string "site"
t.string "company"
@ -419,9 +421,6 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "authentication_token"
t.integer "build_priority", :default => 50
end

View File

@ -129,7 +129,7 @@ describe Groups::ProfileController do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@group.update_attribute(:owner, @user)
@group.owner = @user; @group.save
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
end

View File

@ -126,7 +126,7 @@ describe Platforms::KeyPairsController do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@platform.update_attribute(:owner, @user)
@platform.owner = @user; @platform.save
end
it_should_behave_like 'key_pair platform owner'

View File

@ -23,7 +23,7 @@ shared_examples_for 'mass_build platform owner' do
end
it 'should not be able to perform cancel action if stop_build is true' do
@mass_build.update_attribute(:stop_build, true)
@mass_build.stop_build = true; @mass_build.save
post :cancel, :platform_id => @platform, :id => @mass_build
response.should redirect_to(forbidden_path)
end
@ -133,7 +133,7 @@ describe Platforms::MassBuildsController do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@platform.update_attribute(:owner, @user)
@platform.owner = @user; @platform.save
end
it_should_behave_like 'mass_build platform owner'

View File

@ -104,7 +104,7 @@ describe Platforms::PlatformsController do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@platform.update_attribute(:owner, @user)
@platform.owner = @user; @platform.save
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
end

View File

@ -107,7 +107,7 @@ describe Platforms::RepositoriesController do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@repository.platform.update_attribute(:owner, @user)
@repository.platform.owner = @user; @repository.platform.save
@repository.platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
end

View File

@ -326,8 +326,8 @@ describe Projects::BuildListsController do
describe 'publish_build' do
before {
test_git_commit(build_list.project)
build_list.update_attribute :commit_hash, build_list.project.repo.commits('master').last.id
build_list.update_attribute(:status, BuildList::BUILD_PUBLISH)
build_list.update_column :commit_hash, build_list.project.repo.commits('master').last.id
build_list.update_column(:status, BuildList::BUILD_PUBLISH)
build_list_package
}
@ -337,7 +337,7 @@ describe Projects::BuildListsController do
end
it(:passes) {
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
build_list.update_column(:status, BuildServer::BUILD_STARTED)
do_get(BuildServer::SUCCESS)
response.should be_ok
}
@ -401,7 +401,7 @@ describe Projects::BuildListsController do
describe 'pre_build' do
before do
build_list.update_attribute :status, BuildList::BUILD_PENDING
build_list.update_column :status, BuildList::BUILD_PENDING
end
def do_get
@ -428,29 +428,29 @@ describe Projects::BuildListsController do
context 'with auto_publish' do
it(:passes) {
build_list.update_attribute(:started_at, (Time.now - 1.day))
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
build_list.update_column(:started_at, (Time.now - 1.day))
build_list.update_column(:status, BuildServer::BUILD_STARTED)
build_list.reload
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH)
}
it(:passes) {
build_list.update_attribute(:started_at, (Time.now - 1.day))
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
build_list.update_column(:started_at, (Time.now - 1.day))
build_list.update_column(:status, BuildServer::BUILD_STARTED)
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
}
end
context 'without auto_publish' do
before { build_list.update_attribute(:auto_publish, false) }
before { build_list.update_column(:auto_publish, false) }
it(:passes) {
build_list.update_attribute(:started_at, (Time.now - 1.day))
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
build_list.update_column(:started_at, (Time.now - 1.day))
build_list.update_column(:status, BuildServer::BUILD_STARTED)
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS)
}
it(:passes) {
build_list.update_attribute(:started_at, (Time.now - 1.day))
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
build_list.update_column(:started_at, (Time.now - 1.day))
build_list.update_column(:status, BuildServer::BUILD_STARTED)
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
}
end

View File

@ -1,21 +1,37 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
def create_params
@user_params = {
:actor_id => @another_user.id.to_s,
:actor_type => 'user',
:role => 'reader'
}
@group_params = {
:actor_id => @group.id.to_s,
:actor_type => 'group',
:role => 'reader'
}
@create_params = {
:owner_name => @project.owner.uname, :project_name => @project.name,
:format => :json
}
shared_context "collaborators controller" do
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@another_user = FactoryGirl.create(:user)
@member_user = FactoryGirl.create(:user)
# Create relation with 'writer' rights
@collaborator = Collaborator.create(:actor => @member_user, :project => @project, :role => 'writer')
end
def set_params
@user_params = {
:actor_id => @another_user.id.to_s,
:actor_type => 'user',
:role => 'reader'
}
@group_params = {
:actor_id => @group.id.to_s,
:actor_type => 'group',
:role => 'reader'
} if @group
@create_params = {
:owner_name => @project.owner.uname, :project_name => @project.name,
:format => :json
}
@update_params = {
:owner_name => @project.owner.uname, :project_name => @project.name,
:collaborator => {:role => 'reader'},
:format => :json
}
end
end
shared_examples_for 'project admin user' do
@ -25,7 +41,7 @@ shared_examples_for 'project admin user' do
end
it 'should be able to perform update action' do
put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params)
put :update, {:id => @collaborator.id}.merge(@update_params)
response.should be_success
end
@ -40,7 +56,7 @@ shared_examples_for 'project admin user' do
end
it 'should be able to set reader role for any user' do
put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params)
put :update, {:id => @collaborator.id}.merge(@update_params)
@another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read'
end
end
@ -52,35 +68,28 @@ shared_examples_for 'user with no rights for this project' do
end
it 'should not be able to perform update action' do
put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params)
put :update, {:id => @collaborator.id}.merge(@update_params)
response.should redirect_to(forbidden_path)
end
it 'should not be able to set reader role for any user' do
put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params)
put :update, {:id => @collaborator.id}.merge(@update_params)
!@another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read'
end
end
describe Projects::CollaboratorsController do
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@another_user = FactoryGirl.create(:user)
@member_user = FactoryGirl.create(:user)
@update_params = {:collaborator => {:role => :reader}, :format => :json}
# Create relation with 'writer' rights
@collaborator = Collaborator.create(:actor => @member_user, :project => @project, :role => 'writer')
end
include_context "collaborators controller"
context 'for guest' do
before {set_params}
it 'should not be able to perform index action' do
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
response.should redirect_to(new_user_session_path)
end
it 'should not be able to perform update action' do
put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params)
put :update, {:id => @collaborator.id}.merge(@update_params)
response.code.should == '401'
end
end
@ -90,7 +99,7 @@ describe Projects::CollaboratorsController do
@admin = FactoryGirl.create(:admin)
set_session_for(@admin)
@group = FactoryGirl.create(:group)
create_params
set_params
end
it_should_behave_like 'project admin user'
@ -99,15 +108,13 @@ describe Projects::CollaboratorsController do
context 'for admin user' do
before(:each) do
@user = FactoryGirl.create(:user)
# @user.relations
set_session_for(@user)
@group = FactoryGirl.create(:group)
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
create_params
set_params
end
it_should_behave_like 'project admin user'
end
context 'for owner user' do
@ -116,10 +123,9 @@ describe Projects::CollaboratorsController do
set_session_for(@user)
@group = FactoryGirl.create(:group)
@project.update_attribute(:owner, @user)
@project.owner = @user; @project.save!; @project.reload
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
create_params
set_params
end
it_should_behave_like 'project admin user'
@ -130,6 +136,7 @@ describe Projects::CollaboratorsController do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
set_params
end
it_should_behave_like 'user with no rights for this project'
@ -140,6 +147,7 @@ describe Projects::CollaboratorsController do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
set_params
end
it_should_behave_like 'user with no rights for this project'

View File

@ -1,6 +1,27 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
shared_context "comments controller" do
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user => FactoryGirl.create(:user))
@comment = FactoryGirl.create(:comment, :commentable => @issue, :project_id => @project.id)
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@user = FactoryGirl.create(:user)
set_session_for(@user)
@own_comment = FactoryGirl.create(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
end
def set_params
@create_params = {:comment => {:body => 'I am a comment!'}, :owner_name => @project.owner.uname, :project_name => @project.name, :issue_id => @issue.serial_id}
@update_params = {:comment => {:body => 'updated'}, :owner_name => @project.owner.uname, :project_name => @project.name, :issue_id => @issue.serial_id}
end
end
shared_examples_for 'user with create comment rights' do
it 'should be able to perform create action' do
post :create, @create_params
@ -30,7 +51,7 @@ shared_examples_for 'user with update stranger comment rights' do
response.should redirect_to([@project, @issue])
end
it 'should update issue title' do
it 'should update comment body' do
put :update, {:id => @comment.id}.merge(@update_params)
@comment.reload.body.should == 'updated'
end
@ -42,7 +63,7 @@ shared_examples_for 'user without update stranger comment rights' do
response.should redirect_to(forbidden_path)
end
it 'should not update issue title' do
it 'should not update comment body' do
put :update, {:id => @comment.id}.merge(@update_params)
@comment.reload.body.should_not == 'updated'
end
@ -71,26 +92,12 @@ end
#end
describe Projects::CommentsController do
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :user => FactoryGirl.create(:user))
@comment = FactoryGirl.create(:comment, :commentable => @issue, :project_id => @project.id)
@create_params = {:comment => {:body => 'I am a comment!'}, :owner_name => @project.owner.uname, :project_name => @project.name, :issue_id => @issue.serial_id}
@update_params = {:comment => {:body => 'updated'}, :owner_name => @project.owner.uname, :project_name => @project.name, :issue_id => @issue.serial_id}
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@user = FactoryGirl.create(:user)
set_session_for(@user)
@own_comment = FactoryGirl.create(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
end
include_context "comments controller"
context 'for project admin user' do
before(:each) do
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
set_params
end
it_should_behave_like 'user with create comment rights'
@ -101,10 +108,11 @@ describe Projects::CommentsController do
context 'for project owner user' do
before(:each) do
@project.update_attribute(:owner, @user)
@project.relations.destroy_all
@project.relations.create :actor_id => @project.owner.id, :actor_type => @project.owner.class.to_s, :role => 'admin'
@create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname
@project.owner = @user; @project.save!; @project.reload; @project.owner.reload
# @project.relations.destroy_all
# @project.relations.create! :actor_id => @project.owner_id, :actor_type => @project.owner_type, :role => 'admin'
# @create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname
set_params
end
it_should_behave_like 'user with create comment rights'
@ -116,6 +124,7 @@ describe Projects::CommentsController do
context 'for project reader user' do
before(:each) do
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
set_params
end
it_should_behave_like 'user with create comment rights'
@ -127,6 +136,7 @@ describe Projects::CommentsController do
context 'for project writer user' do
before(:each) do
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
set_params
end
it_should_behave_like 'user with create comment rights'

View File

@ -1,6 +1,40 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
shared_context "issues controller" do
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@issue_user = FactoryGirl.create(:user)
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :assignee_id => @issue_user.id)
@project_with_turned_off_issues = FactoryGirl.create(:project, :has_issues => false)
@turned_of_issue = FactoryGirl.create(:issue, :project_id => @project_with_turned_off_issues.id, :assignee_id => @issue_user.id)
end
def set_params
@create_params = {
:owner_name => @project.owner.uname, :project_name => @project.name,
:issue => {
:title => "issue1",
:body => "issue body"
},
:assignee_id => @issue_user.id,
:assignee_uname => @issue_user.uname
}
@update_params = {
:owner_name => @project.owner.uname, :project_name => @project.name,
:issue => {
:title => "issue2"
}
}
end
end
shared_examples_for 'issue user with project reader rights' do
it 'should be able to perform index action' do
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
@ -13,7 +47,7 @@ shared_examples_for 'issue user with project reader rights' do
end
it 'should be able to perform index action on hidden project' do
@project.update_attribute :visibility, 'hidden'
@project.update_attributes :visibility => 'hidden'
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
response.should render_template(:index)
end
@ -78,39 +112,13 @@ shared_examples_for 'project with issues turned off' do
end
describe Projects::IssuesController do
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project)
@issue_user = FactoryGirl.create(:user)
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@issue = FactoryGirl.create(:issue, :project_id => @project.id, :assignee_id => @issue_user.id)
@create_params = {
:owner_name => @project.owner.uname, :project_name => @project.name,
:issue => {
:title => "issue1",
:body => "issue body"
},
:assignee_id => @issue_user.id,
:assignee_uname => @issue_user.uname
}
@update_params = {
:owner_name => @project.owner.uname, :project_name => @project.name,
:issue => {
:title => "issue2"
}
}
@project_with_turned_off_issues = FactoryGirl.create(:project, :has_issues => false)
@turned_of_issue = FactoryGirl.create(:issue, :project_id => @project_with_turned_off_issues.id, :assignee_id => @issue_user.id)
end
include_context "issues controller"
context 'for global admin user' do
before(:each) do
@admin = FactoryGirl.create(:admin)
set_session_for(@admin)
set_params
end
it_should_behave_like 'user without issue destroy rights'
@ -121,6 +129,7 @@ describe Projects::IssuesController do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
set_params
end
it_should_behave_like 'issue user with project reader rights'
@ -134,8 +143,9 @@ describe Projects::IssuesController do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@project.update_attribute(:owner, @user); @create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname
@project.owner = @user; @project.save!; @project.reload
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
set_params
end
it_should_behave_like 'issue user with project reader rights'
@ -150,6 +160,7 @@ describe Projects::IssuesController do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
set_params
end
it_should_behave_like 'issue user with project reader rights'
@ -172,6 +183,7 @@ describe Projects::IssuesController do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
set_params
end
it_should_behave_like 'issue user with project reader rights'
@ -184,6 +196,7 @@ describe Projects::IssuesController do
context 'for issue assign user' do
before(:each) do
set_session_for(@issue_user)
set_params
end
it_should_behave_like 'user without issue update rights'
@ -192,6 +205,8 @@ describe Projects::IssuesController do
end
context 'for guest' do
before {set_params}
if APP_CONFIG['anonymous_access']
# it_should_behave_like 'issue user with project reader rights'
it 'should be able to perform index action' do
@ -205,7 +220,7 @@ describe Projects::IssuesController do
end
it 'should not be able to perform index action on hidden project' do
@project.update_attribute :visibility, 'hidden'
@project.update_attributes :visibility => 'hidden'
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
response.should redirect_to(forbidden_path)
end
@ -221,7 +236,7 @@ describe Projects::IssuesController do
end
it 'should not be able to perform index action on hidden project' do
@project.update_attribute :visibility, 'hidden'
@project.update_attributes :visibility => 'hidden'
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
response.should redirect_to(new_user_session_path)
end

View File

@ -47,7 +47,7 @@ describe Projects::ProjectsController do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@project.update_attribute(:owner, @user)
@project.owner = @user; @project.save!; @project.reload
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
end
@ -132,7 +132,7 @@ describe Projects::ProjectsController do
end
it 'should not be able to fork hidden project' do
@project.update_attribute(:visibility, 'hidden')
@project.update_attributes(:visibility => 'hidden')
post :fork, :owner_name => @project.owner.uname, :project_name => @project.name
response.should redirect_to(forbidden_path)
end
@ -150,7 +150,7 @@ describe Projects::ProjectsController do
context 'owner of the project' do
before(:each) do
@project.update_attribute :owner, @group
@project.owner = @group; @project.save!; @project.reload
@project.relations.create :actor_id => @project.owner.id, :actor_type => @project.owner.class.to_s, :role => 'admin'
end

View File

@ -6,6 +6,7 @@ FactoryGirl.define do
association :save_to_platform, :factory => :platform_with_repos
association :arch
build_for_platform {|bl| bl.save_to_platform}
save_to_repository {|bl| bl.save_to_platform.repositories.first}
project_version "1.0"
build_requires true
update_type 'security'

View File

@ -2,5 +2,6 @@
FactoryGirl.define do
factory :product_build_list do
association :product, :factory => :product
status 0 # BUILD_COMPLETED
end
end

View File

@ -123,7 +123,7 @@ describe CanCan do
context "private users relations" do
before(:each) do
@private_user = FactoryGirl.create(:private_user)
@private_user.platform.update_attribute(:owner, @user)
@private_user.platform.owner = @user; @private_user.platform.save
end
[:read, :create].each do |action|
@ -207,7 +207,7 @@ describe CanCan do
context 'with owner rights' do
before(:each) do
@project.update_attribute(:owner, @user)
@project.owner = @user; @project.save
@project.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'admin')
@issue.project.reload
end
@ -241,7 +241,7 @@ describe CanCan do
context 'with owner rights' do
before(:each) do
@platform.update_attribute(:owner, @user)
@platform.owner = @user; @platform.save
end
[:read, :update, :destroy].each do |action|
@ -269,7 +269,7 @@ describe CanCan do
context 'with owner rights' do
before(:each) do
@repository.platform.update_attribute(:owner, @user)
@repository.platform.owner = @user; @repository.platform.save
end
[:read, :create, :update, :destroy, :add_project, :remove_project, :change_visibility, :settings].each do |action|

View File

@ -91,7 +91,7 @@ describe Comment do
context 'for disabled notify setting new_comment_commit_repo_owner' do
it 'should not send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_repo_owner, false
@user.notifier.update_column :new_comment_commit_repo_owner, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 1
end
@ -99,7 +99,7 @@ describe Comment do
context 'for disabled notify setting new_comment_commit_owner' do
it 'should send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_owner, false
@user.notifier.update_column :new_comment_commit_owner, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@user.email).should == true
@ -108,7 +108,7 @@ describe Comment do
context 'for disabled notify setting new_comment_commit_commentor' do
it 'should send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_commentor, false
@user.notifier.update_column :new_comment_commit_commentor, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@user.email).should == true
@ -117,9 +117,9 @@ describe Comment do
context 'for disabled all notify setting expect global' do
it 'should not send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_repo_owner, false
@user.notifier.update_attribute :new_comment_commit_owner, false
@user.notifier.update_attribute :new_comment_commit_commentor, false
@user.notifier.update_column :new_comment_commit_repo_owner, false
@user.notifier.update_column :new_comment_commit_owner, false
@user.notifier.update_column :new_comment_commit_commentor, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 0
end
@ -135,7 +135,7 @@ describe Comment do
context 'for disabled global notify setting' do
it 'should not send an e-mail' do
@user.notifier.update_attribute :can_notify, false
@user.notifier.update_column :can_notify, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 0
end
@ -148,7 +148,7 @@ describe Comment do
@user = FactoryGirl.create(:user)
@stranger = FactoryGirl.create(:user)
set_comments_data_for_commit
@project.update_attribute(:owner, @user)
@project.owner = @user; @project.save
ActionMailer::Base.deliveries = []
end
@ -178,7 +178,7 @@ describe Comment do
context 'for disabled notify setting new_comment_commit_repo_owner' do
it 'should not send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_repo_owner, false
@user.notifier.update_column :new_comment_commit_repo_owner, false
Comment.destroy_all
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 0
@ -187,7 +187,7 @@ describe Comment do
context 'for disabled notify setting new_comment_commit_owner' do
it 'should send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_owner, false
@user.notifier.update_column :new_comment_commit_owner, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@user.email).should == true
@ -196,7 +196,7 @@ describe Comment do
context 'for disabled notify setting new_comment_commit_commentor' do
it 'should send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_commentor, false
@user.notifier.update_column :new_comment_commit_commentor, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@user.email).should == true
@ -205,9 +205,9 @@ describe Comment do
context 'for disabled all notify setting expect global' do
it 'should not send an e-mail' do
@user.notifier.update_attribute :new_comment_commit_repo_owner, false
@user.notifier.update_attribute :new_comment_commit_owner, false
@user.notifier.update_attribute :new_comment_commit_commentor, false
@user.notifier.update_column :new_comment_commit_repo_owner, false
@user.notifier.update_column :new_comment_commit_owner, false
@user.notifier.update_column :new_comment_commit_commentor, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 0
end
@ -223,7 +223,7 @@ describe Comment do
context 'for disabled global notify setting' do
it 'should not send an e-mail' do
@user.notifier.update_attribute :can_notify, false
@user.notifier.update_column :can_notify, false
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 0
end
@ -231,7 +231,7 @@ describe Comment do
context 'for own commit' do
it 'should send a one e-mail' do
@project.owner.update_attribute :email, 'code@tpope.net'
@project.owner.update_column :email, 'code@tpope.net'
comment = create_comment(@stranger)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@project.owner.email).should == true
@ -298,7 +298,7 @@ describe Comment do
context 'for committer' do
it 'should send an e-mail' do
@simple.update_attribute :email, 'code@tpope.net'
@simple.update_column :email, 'code@tpope.net'
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@simple.email).should == true
@ -306,30 +306,30 @@ describe Comment do
it 'should send a one e-mail when subscribed to commit' do
Subscribe.subscribe_to_commit @subscribe_params.merge(:user_id => @simple.id)
@simple.update_attribute :email, 'code@tpope.net'
@simple.update_column :email, 'code@tpope.net'
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@simple.email).should == true
end
it 'should not send an e-mail for own comment' do
@simple.update_attribute :email, 'code@tpope.net'
@simple.update_column :email, 'code@tpope.net'
comment = create_comment(@simple)
ActionMailer::Base.deliveries.count.should == 0
end
it 'should not send an e-mail if global notify off' do
@project.owner.notifier.update_attribute :can_notify, false
@simple.update_attribute :email, 'code@tpope.net'
@simple.notifier.update_attribute :can_notify, false
@project.owner.notifier.update_column :can_notify, false
@simple.update_column :email, 'code@tpope.net'
@simple.notifier.update_column :can_notify, false
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 0
end
it 'should not send an e-mail if notify for my commits off' do
Comment.destroy_all
@simple.notifier.update_attribute :new_comment_commit_owner, false
@simple.update_attribute :email, 'code@tpope.net'
@simple.notifier.update_column :new_comment_commit_owner, false
@simple.update_column :email, 'code@tpope.net'
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 0
end

View File

@ -84,7 +84,7 @@ describe Comment do
set_commentable_data
@project.update_attribute(:owner, @user)
@project.owner = @user; @project.save
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
end

View File

@ -62,7 +62,7 @@ describe Group do
context 'for group owner' do
before(:each) do
@user = FactoryGirl.create(:user)
@group.update_attribute(:owner, @user)
@group.owner = @user; @group.save
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
@ability = Ability.new(@user)
end

View File

@ -45,7 +45,7 @@ describe User do
context 'for group project' do
before(:each) do
@project.relations.destroy_all
@project.update_attribute :owner, @group
@project.owner = @group; @project.save
@project.relations.create :actor_id => @project.owner.id, :actor_type => @project.owner.class.to_s, :role => 'admin'
end