mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Upgrade ruby to 2.2.2. Bump rails to 3.2.22
- Upgrade RSpec to 3.3 - Auto formatted existing specs - Fixes broken test assertions - Update capistrano rbenv_ruby to target 2.2.2 - Added test-unit as test dependency as it has been removed form ruby 2.2
This commit is contained in:
parent
07df9a8db6
commit
cef4b0009c
12 changed files with 298 additions and 258 deletions
9
Gemfile
9
Gemfile
|
@ -1,9 +1,9 @@
|
|||
source 'http://rubygems.org'
|
||||
|
||||
ruby '2.1.5'
|
||||
ruby '2.2.2'
|
||||
|
||||
gem 'dotenv-rails', '~> 0.10.0'
|
||||
gem 'rails', '~> 3.2.19'
|
||||
gem 'rails', '~> 3.2.22'
|
||||
gem 'mysql2', '~> 0.3.15'
|
||||
gem 'dalli', '~> 2.7.0'
|
||||
gem 'puma', '~> 2.11.1'
|
||||
|
@ -59,12 +59,13 @@ group :test do
|
|||
gem 'simplecov', '~> 0.7.1', require: false
|
||||
gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil
|
||||
gem 'database_cleaner', '~> 1.2.0'
|
||||
gem 'rspec-rails', '~> 2.14.1'
|
||||
gem 'capybara', '~> 2.2.1'
|
||||
gem 'rspec-rails', '~> 3.3.3'
|
||||
gem 'capybara', '~> 2.4.4'
|
||||
gem 'poltergeist', '~> 1.6.0'
|
||||
gem 'selenium-webdriver', '~> 2.41.0'
|
||||
gem 'factory_girl_rails', '~> 4.4.1'
|
||||
gem 'timecop', '~> 0.7.1'
|
||||
gem 'test-unit', '~> 3.1.3'
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
|
|
114
Gemfile.lock
114
Gemfile.lock
|
@ -9,12 +9,12 @@ GIT
|
|||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.19)
|
||||
actionpack (= 3.2.19)
|
||||
actionmailer (3.2.22)
|
||||
actionpack (= 3.2.22)
|
||||
mail (~> 2.5.4)
|
||||
actionpack (3.2.19)
|
||||
activemodel (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
actionpack (3.2.22)
|
||||
activemodel (= 3.2.22)
|
||||
activesupport (= 3.2.22)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
journey (~> 1.0.4)
|
||||
|
@ -24,18 +24,18 @@ GEM
|
|||
sprockets (~> 2.2.1)
|
||||
active_link_to (1.0.2)
|
||||
actionpack
|
||||
activemodel (3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
activemodel (3.2.22)
|
||||
activesupport (= 3.2.22)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.19)
|
||||
activemodel (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
activerecord (3.2.22)
|
||||
activemodel (= 3.2.22)
|
||||
activesupport (= 3.2.22)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.19)
|
||||
activemodel (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
activesupport (3.2.19)
|
||||
activeresource (3.2.22)
|
||||
activemodel (= 3.2.22)
|
||||
activesupport (= 3.2.22)
|
||||
activesupport (3.2.22)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
multi_json (~> 1.0)
|
||||
annotate (2.6.3)
|
||||
|
@ -69,7 +69,7 @@ GEM
|
|||
capistrano-rbenv (2.0.2)
|
||||
capistrano (~> 3.1)
|
||||
sshkit (~> 1.3)
|
||||
capybara (2.2.1)
|
||||
capybara (2.4.4)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
|
@ -122,19 +122,19 @@ GEM
|
|||
haml (4.0.5)
|
||||
tilt
|
||||
hike (1.2.3)
|
||||
i18n (0.6.11)
|
||||
i18n (0.7.0)
|
||||
journey (1.0.4)
|
||||
jquery-rails (2.0.3)
|
||||
railties (>= 3.1.0, < 5.0)
|
||||
thor (~> 0.14)
|
||||
json (1.8.1)
|
||||
json (1.8.3)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.5.3)
|
||||
multi_json (1.10.1)
|
||||
mini_portile (0.6.2)
|
||||
multi_json (1.11.2)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
mysql2 (0.3.15)
|
||||
|
@ -145,8 +145,8 @@ GEM
|
|||
net-ssh (>= 2.6.5)
|
||||
net-ssh (2.9.0)
|
||||
newrelic_rpm (3.7.2.195)
|
||||
nokogiri (1.6.1)
|
||||
mini_portile (~> 0.5.0)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
oj (2.5.5)
|
||||
poltergeist (1.6.0)
|
||||
capybara (~> 2.1)
|
||||
|
@ -154,6 +154,7 @@ GEM
|
|||
multi_json (~> 1.0)
|
||||
websocket-driver (>= 0.2.0)
|
||||
polyglot (0.3.5)
|
||||
power_assert (0.2.4)
|
||||
pry (0.9.12.6)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
|
@ -165,46 +166,51 @@ GEM
|
|||
rack (>= 1.1, < 2.0)
|
||||
quiet_assets (1.0.2)
|
||||
railties (>= 3.1, < 5.0)
|
||||
rack (1.4.5)
|
||||
rack (1.4.7)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-ssl (1.3.4)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.19)
|
||||
actionmailer (= 3.2.19)
|
||||
actionpack (= 3.2.19)
|
||||
activerecord (= 3.2.19)
|
||||
activeresource (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
rails (3.2.22)
|
||||
actionmailer (= 3.2.22)
|
||||
actionpack (= 3.2.22)
|
||||
activerecord (= 3.2.22)
|
||||
activeresource (= 3.2.22)
|
||||
activesupport (= 3.2.22)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.19)
|
||||
railties (= 3.2.22)
|
||||
rails_autolink (1.1.5)
|
||||
rails (> 3.1)
|
||||
railties (3.2.19)
|
||||
actionpack (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
railties (3.2.22)
|
||||
actionpack (= 3.2.22)
|
||||
activesupport (= 3.2.22)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.3.2)
|
||||
rake (10.4.2)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
rmagick (2.13.4)
|
||||
rspec-core (2.14.8)
|
||||
rspec-expectations (2.14.5)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.14.6)
|
||||
rspec-rails (2.14.2)
|
||||
actionpack (>= 3.0)
|
||||
activemodel (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 2.14.0)
|
||||
rspec-expectations (~> 2.14.0)
|
||||
rspec-mocks (~> 2.14.0)
|
||||
rspec-core (3.3.2)
|
||||
rspec-support (~> 3.3.0)
|
||||
rspec-expectations (3.3.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.3.0)
|
||||
rspec-mocks (3.3.2)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.3.0)
|
||||
rspec-rails (3.3.3)
|
||||
actionpack (>= 3.0, < 4.3)
|
||||
activesupport (>= 3.0, < 4.3)
|
||||
railties (>= 3.0, < 4.3)
|
||||
rspec-core (~> 3.3.0)
|
||||
rspec-expectations (~> 3.3.0)
|
||||
rspec-mocks (~> 3.3.0)
|
||||
rspec-support (~> 3.3.0)
|
||||
rspec-support (3.3.0)
|
||||
rubyzip (1.1.3)
|
||||
sanitize (2.1.0)
|
||||
nokogiri (>= 1.4.4)
|
||||
|
@ -223,7 +229,7 @@ GEM
|
|||
simplecov-html (~> 0.7.1)
|
||||
simplecov-html (0.7.1)
|
||||
slop (3.5.0)
|
||||
sprockets (2.2.2)
|
||||
sprockets (2.2.3)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
|
@ -234,6 +240,8 @@ GEM
|
|||
term-ansicolor
|
||||
term-ansicolor (1.3.0)
|
||||
tins (~> 1.0)
|
||||
test-unit (3.1.3)
|
||||
power_assert
|
||||
thor (0.19.1)
|
||||
tilt (1.4.1)
|
||||
timecop (0.7.1)
|
||||
|
@ -243,7 +251,7 @@ GEM
|
|||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.41)
|
||||
tzinfo (0.3.44)
|
||||
uglifier (2.5.0)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
|
@ -270,7 +278,7 @@ DEPENDENCIES
|
|||
capistrano-bundler (~> 1.1.2)
|
||||
capistrano-rails (~> 1.1)
|
||||
capistrano-rbenv (~> 2.0.2)
|
||||
capybara (~> 2.2.1)
|
||||
capybara (~> 2.4.4)
|
||||
carrierwave (~> 0.10.0)
|
||||
codeclimate-test-reporter (~> 0.3.0)
|
||||
coffee-rails (~> 3.2.2)
|
||||
|
@ -294,10 +302,10 @@ DEPENDENCIES
|
|||
pry-byebug (~> 1.3.2)
|
||||
puma (~> 2.11.1)
|
||||
quiet_assets (~> 1.0.2)
|
||||
rails (~> 3.2.19)
|
||||
rails (~> 3.2.22)
|
||||
rails_autolink (~> 1.1.5)
|
||||
rmagick (~> 2.13.4)
|
||||
rspec-rails (~> 2.14.1)
|
||||
rspec-rails (~> 3.3.3)
|
||||
sanitize (~> 2.1.0)
|
||||
sass (~> 3.3.4)
|
||||
sass-rails (~> 3.2.6)
|
||||
|
@ -305,7 +313,11 @@ DEPENDENCIES
|
|||
simplecov (~> 0.7.1)
|
||||
sprockets (~> 2.2.1)
|
||||
steam-condenser!
|
||||
test-unit (~> 3.1.3)
|
||||
timecop (~> 0.7.1)
|
||||
tinymce-rails (~> 3.5.9)
|
||||
uglifier (~> 2.5.0)
|
||||
will_paginate (~> 3.0.5)
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.5
|
||||
|
|
|
@ -9,7 +9,7 @@ set :repo_url, 'https://github.com/ENSL/ensl.org.git'
|
|||
set :keep_releases, 10
|
||||
|
||||
set :rbenv_type, :user
|
||||
set :rbenv_ruby, '2.1.5'
|
||||
set :rbenv_ruby, '2.2.2'
|
||||
set :bundle_flags, '--quiet'
|
||||
set :dotenv_role, [:app, :web]
|
||||
|
||||
|
@ -18,10 +18,10 @@ set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
|
|||
|
||||
set :writable_dirs, %w{public tmp}
|
||||
set :linked_files, %w{.env}
|
||||
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle
|
||||
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle
|
||||
public/system public/local public/uploads public/files}
|
||||
|
||||
set :normalize_asset_timestamps, %{public/images
|
||||
set :normalize_asset_timestamps, %{public/images
|
||||
public/javascripts
|
||||
public/stylesheets}
|
||||
|
||||
|
@ -89,4 +89,4 @@ namespace :puma do
|
|||
def valid_pid?
|
||||
test "[ -f #{fetch(:puma_pid)} ]" and test "kill -0 $( cat #{fetch(:puma_pid)} )"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe Api::V1::MapsController do
|
||||
before do
|
||||
request.accept = 'application/json'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
let!(:map) { create :map }
|
||||
|
@ -16,4 +16,5 @@ describe Api::V1::MapsController do
|
|||
expect(json_map['id']).to eq(map.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe Api::V1::ServersController do
|
||||
before do
|
||||
request.accept = 'application/json'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
let!(:server) { create :server, :active }
|
||||
|
@ -17,4 +17,5 @@ describe Api::V1::ServersController do
|
|||
expect(json_server['id']).to eq(server.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -40,18 +40,21 @@ describe Api::V1::UsersController do
|
|||
expect(response).to be_success
|
||||
expect(json['bans']['mute']).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns correct ban if user gather banned' do
|
||||
create :ban, :gather, user: @user
|
||||
get :show, id: @user.id
|
||||
expect(response).to be_success
|
||||
expect(json['bans']['gather']).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns correct ban if user site banned' do
|
||||
create :ban, :site, user: @user
|
||||
get :show, id: @user.id
|
||||
expect(response).to be_success
|
||||
expect(json['bans']['site']).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns team information' do
|
||||
@user.destroy
|
||||
@user_with_team = create :user_with_team, :chris
|
||||
|
@ -81,7 +84,7 @@ describe Api::V1::UsersController do
|
|||
|
||||
user_json = json["users"].first
|
||||
nested_team_json = user_json["team"]
|
||||
|
||||
|
||||
expect(user_json).to have_key("username")
|
||||
expect(user_json).to have_key("steamid")
|
||||
expect(user_json).to have_key("team")
|
||||
|
@ -91,3 +94,4 @@ describe Api::V1::UsersController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,56 +18,61 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Ban do
|
||||
let!(:user) { create :user }
|
||||
let(:ban) { Ban.new }
|
||||
let!(:server) { create :server }
|
||||
let!(:user) { create :user }
|
||||
let(:ban) { Ban.new }
|
||||
let!(:server) { create :server }
|
||||
|
||||
describe '#check_user' do
|
||||
it "assigns user by user_name" do
|
||||
ban.user_name = user.username
|
||||
ban.check_user
|
||||
expect(ban.user).to eq(user)
|
||||
end
|
||||
it "assigns user and server if user_name not present" do
|
||||
ban.steamid = user.steamid
|
||||
ban.addr = server.addr
|
||||
ban.check_user
|
||||
expect(ban.user).to eq(user)
|
||||
expect(ban.server).to eq(server)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Permissions' do
|
||||
let!(:user) { create :user }
|
||||
let!(:admin) { create :user, :admin }
|
||||
let!(:server_user) { create :user }
|
||||
let(:ban) { Ban.new }
|
||||
describe '#check_user' do
|
||||
it "assigns user by user_name" do
|
||||
ban.user_name = user.username
|
||||
ban.check_user
|
||||
expect(ban.user).to eq(user)
|
||||
end
|
||||
|
||||
describe 'can_create?' do
|
||||
it 'returns true for admins' do
|
||||
expect(ban.can_create? admin).to be_true
|
||||
end
|
||||
it 'returns false for non-admins' do
|
||||
expect(ban.can_create? user).to be_false
|
||||
end
|
||||
end
|
||||
it "assigns user and server if user_name not present" do
|
||||
ban.steamid = user.steamid
|
||||
ban.addr = server.addr
|
||||
ban.check_user
|
||||
expect(ban.user).to eq(user)
|
||||
expect(ban.server).to eq(server)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_destroy?' do
|
||||
it 'returns true for admin' do
|
||||
expect(ban.can_destroy? admin).to be_true
|
||||
end
|
||||
it 'returns false for non-admins' do
|
||||
expect(ban.can_destroy? user).to be_false
|
||||
end
|
||||
end
|
||||
describe 'Permissions' do
|
||||
let!(:user) { create :user }
|
||||
let!(:admin) { create :user, :admin }
|
||||
let!(:server_user) { create :user }
|
||||
let(:ban) { Ban.new }
|
||||
|
||||
describe 'can_update?' do
|
||||
it 'returns true for admin' do
|
||||
expect(ban.can_update? admin).to be_true
|
||||
end
|
||||
it 'returns false for non-admins' do
|
||||
expect(ban.can_update? user).to be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'can_create?' do
|
||||
it 'returns true for admins' do
|
||||
expect(ban.can_create? admin).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false for non-admins' do
|
||||
expect(ban.can_create? user).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_destroy?' do
|
||||
it 'returns true for admin' do
|
||||
expect(ban.can_destroy? admin).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false for non-admins' do
|
||||
expect(ban.can_destroy? user).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_update?' do
|
||||
it 'returns true for admin' do
|
||||
expect(ban.can_update? admin).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false for non-admins' do
|
||||
expect(ban.can_update? user).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,43 +18,50 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'User' do
|
||||
describe 'Permissions' do
|
||||
let!(:user) { create :user }
|
||||
let!(:admin) { create :user, :admin }
|
||||
let(:issue) { Issue.new }
|
||||
describe 'Permissions' do
|
||||
let!(:user) { create :user }
|
||||
let!(:admin) { create :user, :admin }
|
||||
let(:issue) { Issue.new }
|
||||
|
||||
describe 'can_show?' do
|
||||
it 'returns true for author' do
|
||||
issue.author = user
|
||||
expect(issue.can_show? user).to be_true
|
||||
end
|
||||
it 'returns true for admin' do
|
||||
expect(issue.can_show? admin).to be_true
|
||||
end
|
||||
it 'returns false if neither admin nor author' do
|
||||
expect(issue.can_show? user).to be_false
|
||||
end
|
||||
end
|
||||
describe 'can_create?' do
|
||||
it "returns true" do
|
||||
expect(issue.can_create? nil).to be_true
|
||||
end
|
||||
end
|
||||
describe 'can_update?' do
|
||||
it 'returns true for admin' do
|
||||
expect(issue.can_update? admin).to be_true
|
||||
end
|
||||
it 'returns false for non-admin' do
|
||||
expect(issue.can_update? user).to be_false
|
||||
end
|
||||
end
|
||||
describe 'can_destroy?' do
|
||||
it 'returns true for admin' do
|
||||
expect(issue.can_destroy? admin).to be_true
|
||||
end
|
||||
it 'returns false for non-admin' do
|
||||
expect(issue.can_destroy? user).to be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'can_show?' do
|
||||
it 'returns true for author' do
|
||||
issue.author = user
|
||||
expect(issue.can_show? user).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns true for admin' do
|
||||
expect(issue.can_show? admin).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false if neither admin nor author' do
|
||||
expect(issue.can_show? user).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_create?' do
|
||||
it "returns true" do
|
||||
expect(issue.can_create? nil).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_update?' do
|
||||
it 'returns true for admin' do
|
||||
expect(issue.can_update? admin).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false for non-admin' do
|
||||
expect(issue.can_update? user).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_destroy?' do
|
||||
it 'returns true for admin' do
|
||||
expect(issue.can_destroy? admin).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false for non-admin' do
|
||||
expect(issue.can_destroy? user).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,41 +17,48 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Message do
|
||||
let!(:user) { create :user }
|
||||
let!(:user) { create :user }
|
||||
|
||||
describe 'create' do
|
||||
let(:message) { build :message }
|
||||
it 'creates a new message' do
|
||||
expect(message.valid?).to be_true
|
||||
expect do
|
||||
message.save!
|
||||
end.to change(Message, :count).by(1)
|
||||
end
|
||||
end
|
||||
describe 'create' do
|
||||
let(:message) { build :message }
|
||||
|
||||
describe 'Permissions' do
|
||||
let(:message) { Message.new }
|
||||
describe 'can_create?' do
|
||||
it 'returns true for user' do
|
||||
expect(message.can_create?(user)).to be_true
|
||||
end
|
||||
it 'returns false if user is banned' do
|
||||
create :ban, :mute, user: user
|
||||
expect(message.can_create?(user)).to be_false
|
||||
end
|
||||
end
|
||||
it 'creates a new message' do
|
||||
expect(message.valid?).to eq(true)
|
||||
expect do
|
||||
message.save!
|
||||
end.to change(Message, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Permissions' do
|
||||
let(:message) { Message.new }
|
||||
|
||||
describe 'can_create?' do
|
||||
it 'returns true for user' do
|
||||
expect(message.can_create?(user)).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false if user is banned' do
|
||||
create :ban, :mute, user: user
|
||||
expect(message.can_create?(user)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_show?' do
|
||||
let!(:message) { create :message }
|
||||
|
||||
it 'returns true if sender' do
|
||||
expect(message.can_show?(message.sender)).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns true if receiver' do
|
||||
expect(message.can_show?(message.recipient)).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false if neither sender nor receiver' do
|
||||
expect(message.can_show?(user)).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_show?' do
|
||||
let!(:message) { create :message }
|
||||
it 'returns true if sender' do
|
||||
expect(message.can_show?(message.sender)).to be_true
|
||||
end
|
||||
it 'returns true if receiver' do
|
||||
expect(message.can_show?(message.recipient)).to be_true
|
||||
end
|
||||
it 'returns false if neither sender nor receiver' do
|
||||
expect(message.can_show?(user)).to be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -33,65 +33,66 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Server do
|
||||
describe 'create' do
|
||||
it 'sets category to 45 if domain is NS2' do
|
||||
server = create :server, domain: Server::DOMAIN_NS2
|
||||
expect(server.category_id).to eq(45)
|
||||
end
|
||||
it 'sets category to 44 if domain is not NS2' do
|
||||
server = create :server, domain: Server::DOMAIN_HLDS
|
||||
expect(server.category_id).to eq(44)
|
||||
end
|
||||
end
|
||||
describe 'create' do
|
||||
it 'sets category to 45 if domain is NS2' do
|
||||
server = create :server, domain: Server::DOMAIN_NS2
|
||||
expect(server.category_id).to eq(45)
|
||||
end
|
||||
it 'sets category to 44 if domain is not NS2' do
|
||||
server = create :server, domain: Server::DOMAIN_HLDS
|
||||
expect(server.category_id).to eq(44)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'addr' do
|
||||
it 'returns properly formatted IP and port number' do
|
||||
ip = '1.1.1.1'
|
||||
port = '8000'
|
||||
server = create :server, ip: ip, port: port
|
||||
expect(server.addr).to eq('1.1.1.1:8000')
|
||||
end
|
||||
end
|
||||
describe 'addr' do
|
||||
it 'returns properly formatted IP and port number' do
|
||||
ip = '1.1.1.1'
|
||||
port = '8000'
|
||||
server = create :server, ip: ip, port: port
|
||||
expect(server.addr).to eq('1.1.1.1:8000')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'to_s' do
|
||||
it 'returns server name' do
|
||||
server_name = "Foo"
|
||||
server = create :server, name: server_name
|
||||
expect(server.to_s).to eq(server_name)
|
||||
end
|
||||
end
|
||||
describe 'to_s' do
|
||||
it 'returns server name' do
|
||||
server_name = "Foo"
|
||||
server = create :server, name: server_name
|
||||
expect(server.to_s).to eq(server_name)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Permissions' do
|
||||
let!(:user) { create :user }
|
||||
let!(:admin) { create :user, :admin }
|
||||
let!(:server_user) {create :user }
|
||||
let!(:server) { create :server, user: server_user }
|
||||
describe 'Permissions' do
|
||||
let!(:user) { create :user }
|
||||
let!(:admin) { create :user, :admin }
|
||||
let!(:server_user) {create :user }
|
||||
let!(:server) { create :server, user: server_user }
|
||||
|
||||
describe 'can_create?' do
|
||||
it 'returns true for non-admins' do
|
||||
expect(server.can_create? user).to be_true
|
||||
end
|
||||
end
|
||||
describe 'can_create?' do
|
||||
it 'returns true for non-admins' do
|
||||
expect(server.can_create? user).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_destroy?' do
|
||||
it 'returns true for admin' do
|
||||
expect(server.can_destroy? admin).to be_true
|
||||
end
|
||||
it 'returns false for non-admins' do
|
||||
expect(server.can_destroy? user).to be_false
|
||||
end
|
||||
end
|
||||
describe 'can_destroy?' do
|
||||
it 'returns true for admin' do
|
||||
expect(server.can_destroy? admin).to eq(true)
|
||||
end
|
||||
it 'returns false for non-admins' do
|
||||
expect(server.can_destroy? user).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_update?' do
|
||||
it 'returns true for admin' do
|
||||
expect(server.can_update? admin).to be_true
|
||||
end
|
||||
it 'returns true if server belongs to user' do
|
||||
expect(server.can_update? server_user).to be_true
|
||||
end
|
||||
it 'returns false for non-admins' do
|
||||
expect(server.can_update? user).to be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'can_update?' do
|
||||
it 'returns true for admin' do
|
||||
expect(server.can_update? admin).to eq(true)
|
||||
end
|
||||
it 'returns true if server belongs to user' do
|
||||
expect(server.can_update? server_user).to eq(true)
|
||||
end
|
||||
it 'returns false for non-admins' do
|
||||
expect(server.can_update? user).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,21 +24,21 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe User do
|
||||
let!(:user) { create :user }
|
||||
|
||||
describe "#banned?" do
|
||||
it "returns false if user is not banned" do
|
||||
expect(user.banned?).to be_false
|
||||
end
|
||||
let!(:user) { create :user }
|
||||
|
||||
it "returns true if user is banned" do
|
||||
ban = Ban.create! ban_type: Ban::TYPE_SITE, expiry: Time.now + 10.days, user_name: user.username
|
||||
expect(user.banned?).to be_true
|
||||
end
|
||||
describe "#banned?" do
|
||||
it "returns false if user is not banned" do
|
||||
expect(user.banned?).to be_falsey
|
||||
end
|
||||
|
||||
it "returns true for specific bans" do
|
||||
ban = Ban.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days, user_name: user.username
|
||||
expect(user.banned? Ban::TYPE_MUTE).to be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
it "returns true if user is banned" do
|
||||
ban = Ban.create! ban_type: Ban::TYPE_SITE, expiry: Time.now + 10.days, user_name: user.username
|
||||
expect(user.banned?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns true for specific bans" do
|
||||
ban = Ban.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days, user_name: user.username
|
||||
expect(user.banned? Ban::TYPE_MUTE).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ require 'rspec/rails'
|
|||
require 'capybara/rspec'
|
||||
require 'capybara/poltergeist'
|
||||
|
||||
Capybara.default_wait_time = 30
|
||||
Capybara.default_wait_time = 5
|
||||
Capybara.register_driver :poltergeist do |app|
|
||||
Capybara::Poltergeist::Driver.new(app,
|
||||
timeout: 30,
|
||||
|
@ -34,6 +34,7 @@ RSpec.configure do |config|
|
|||
config.use_transactional_fixtures = false
|
||||
config.color = true
|
||||
config.formatter = :documentation
|
||||
config.infer_spec_type_from_file_location!
|
||||
|
||||
config.before(:each) do
|
||||
events_list_json = JSON.parse(File.read(Rails.root.join('spec/fixtures/google_calendar.json')))
|
||||
|
|
Loading…
Reference in a new issue