mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-25 20:11:34 +00:00
Changed newrelic configuration to load from environment variables
Changed login field text Changed database configuration connection pool size to be configured via dotenv Use a single BBcode parser library Added better translations coverage Code formatting Increases maximum article text limit Added database cleaner with the deletion strategy during testing
This commit is contained in:
parent
95113d0750
commit
24eabf89e6
35 changed files with 277 additions and 180 deletions
|
@ -1,12 +1,17 @@
|
||||||
|
RACK_ENV=
|
||||||
RAILS_ENV=
|
RAILS_ENV=
|
||||||
APP_SECRET=
|
APP_SECRET=
|
||||||
|
|
||||||
UNICORN_USER=deploy
|
UNICORN_USER=deploy
|
||||||
UNICORN_GROUP=deploy
|
UNICORN_GROUP=deploy
|
||||||
UNICORN_WORKERS=4
|
UNICORN_WORKERS=4
|
||||||
UNICORN_PORT=5000
|
UNICORN_PORT=4000
|
||||||
UNICORN_SOCKET=/tmp/unicorn.ensl.sock
|
UNICORN_SOCKET=/tmp/unicorn.ensl.sock
|
||||||
|
|
||||||
MYSQL_DATABASE=ensl
|
MYSQL_DATABASE=ensl
|
||||||
MYSQL_USERNAME=
|
MYSQL_USERNAME=
|
||||||
MYSQL_PASSWORD=
|
MYSQL_PASSWORD=
|
||||||
|
MYSQL_CONNECTION_POOL=8
|
||||||
|
|
||||||
|
NEW_RELIC_APP_NAME=ENSL
|
||||||
|
NEW_RELIC_LICENSE_KEY=
|
||||||
|
|
6
Gemfile
6
Gemfile
|
@ -13,11 +13,11 @@ gem 'sass-rails', '~> 3.2.5'
|
||||||
gem 'coffee-rails', '~> 3.2.2'
|
gem 'coffee-rails', '~> 3.2.2'
|
||||||
gem 'gruff', '~> 0.3.6'
|
gem 'gruff', '~> 0.3.6'
|
||||||
gem 'nokogiri', '~> 1.6.1'
|
gem 'nokogiri', '~> 1.6.1'
|
||||||
gem 'rbbcode', '~> 0.1.11'
|
gem 'bbcoder', '~> 1.0.1'
|
||||||
|
gem 'sanitize', '~> 2.1.0'
|
||||||
gem 'tinymce-rails', '~> 3.5.4.1'
|
gem 'tinymce-rails', '~> 3.5.4.1'
|
||||||
gem 'carrierwave', '~> 0.10.0'
|
gem 'carrierwave', '~> 0.10.0'
|
||||||
gem 'bluecloth', '~> 2.2.0'
|
gem 'bluecloth', '~> 2.2.0'
|
||||||
gem 'bb-ruby', '~> 1.0.4'
|
|
||||||
gem 'therubyracer', '~> 0.12.1'
|
gem 'therubyracer', '~> 0.12.1'
|
||||||
gem 'newrelic_rpm', '~> 3.7.2.195'
|
gem 'newrelic_rpm', '~> 3.7.2.195'
|
||||||
gem 'rmagick', '~> 2.13.2', require: false
|
gem 'rmagick', '~> 2.13.2', require: false
|
||||||
|
@ -39,10 +39,12 @@ end
|
||||||
group :test do
|
group :test do
|
||||||
gem 'simplecov', '~> 0.7.1', require: false
|
gem 'simplecov', '~> 0.7.1', require: false
|
||||||
gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil
|
gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil
|
||||||
|
gem 'database_cleaner', '~> 1.2.0'
|
||||||
gem 'rspec-rails', '~> 2.14.1'
|
gem 'rspec-rails', '~> 2.14.1'
|
||||||
gem 'rspec-given', '~> 3.5.4'
|
gem 'rspec-given', '~> 3.5.4'
|
||||||
gem 'capybara', '~> 2.2.1'
|
gem 'capybara', '~> 2.2.1'
|
||||||
gem 'poltergeist', '~> 1.5.0'
|
gem 'poltergeist', '~> 1.5.0'
|
||||||
|
gem 'selenium-webdriver', '~> 2.41.0'
|
||||||
gem 'factory_girl_rails', '~> 4.4.1'
|
gem 'factory_girl_rails', '~> 4.4.1'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
25
Gemfile.lock
25
Gemfile.lock
|
@ -39,7 +39,7 @@ GEM
|
||||||
activerecord (>= 2.3.0)
|
activerecord (>= 2.3.0)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
arel (3.0.3)
|
arel (3.0.3)
|
||||||
bb-ruby (1.0.4)
|
bbcoder (1.0.1)
|
||||||
bluecloth (2.2.0)
|
bluecloth (2.2.0)
|
||||||
builder (3.0.4)
|
builder (3.0.4)
|
||||||
capistrano (3.1.0)
|
capistrano (3.1.0)
|
||||||
|
@ -68,6 +68,8 @@ GEM
|
||||||
activesupport (>= 3.2.0)
|
activesupport (>= 3.2.0)
|
||||||
json (>= 1.7)
|
json (>= 1.7)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
|
childprocess (0.5.2)
|
||||||
|
ffi (~> 1.0, >= 1.0.11)
|
||||||
cliver (0.3.2)
|
cliver (0.3.2)
|
||||||
codeclimate-test-reporter (0.3.0)
|
codeclimate-test-reporter (0.3.0)
|
||||||
simplecov (>= 0.7.1, < 1.0.0)
|
simplecov (>= 0.7.1, < 1.0.0)
|
||||||
|
@ -81,6 +83,7 @@ GEM
|
||||||
coffee-script-source (1.3.3)
|
coffee-script-source (1.3.3)
|
||||||
columnize (0.3.6)
|
columnize (0.3.6)
|
||||||
dalli (2.7.0)
|
dalli (2.7.0)
|
||||||
|
database_cleaner (1.2.0)
|
||||||
debugger (1.6.6)
|
debugger (1.6.6)
|
||||||
columnize (>= 0.3.1)
|
columnize (>= 0.3.1)
|
||||||
debugger-linecache (~> 1.2.0)
|
debugger-linecache (~> 1.2.0)
|
||||||
|
@ -99,6 +102,8 @@ GEM
|
||||||
factory_girl_rails (4.4.1)
|
factory_girl_rails (4.4.1)
|
||||||
factory_girl (~> 4.4.0)
|
factory_girl (~> 4.4.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
|
ffi (1.9.3)
|
||||||
|
ffi (1.9.3-x86-mingw32)
|
||||||
given_core (3.5.4)
|
given_core (3.5.4)
|
||||||
sorcerer (>= 0.3.7)
|
sorcerer (>= 0.3.7)
|
||||||
gruff (0.3.6)
|
gruff (0.3.6)
|
||||||
|
@ -170,8 +175,6 @@ GEM
|
||||||
thor (>= 0.14.6, < 2.0)
|
thor (>= 0.14.6, < 2.0)
|
||||||
raindrops (0.13.0)
|
raindrops (0.13.0)
|
||||||
rake (10.1.1)
|
rake (10.1.1)
|
||||||
rbbcode (0.1.11)
|
|
||||||
sanitize-url (>= 0.1.3)
|
|
||||||
rdoc (3.12.2)
|
rdoc (3.12.2)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
ref (1.0.5)
|
ref (1.0.5)
|
||||||
|
@ -195,12 +198,19 @@ GEM
|
||||||
rspec-core (~> 2.14.0)
|
rspec-core (~> 2.14.0)
|
||||||
rspec-expectations (~> 2.14.0)
|
rspec-expectations (~> 2.14.0)
|
||||||
rspec-mocks (~> 2.14.0)
|
rspec-mocks (~> 2.14.0)
|
||||||
sanitize-url (0.1.4)
|
rubyzip (1.1.2)
|
||||||
|
sanitize (2.1.0)
|
||||||
|
nokogiri (>= 1.4.4)
|
||||||
sass (3.1.20)
|
sass (3.1.20)
|
||||||
sass-rails (3.2.5)
|
sass-rails (3.2.5)
|
||||||
railties (~> 3.2.0)
|
railties (~> 3.2.0)
|
||||||
sass (>= 3.1.10)
|
sass (>= 3.1.10)
|
||||||
tilt (~> 1.3)
|
tilt (~> 1.3)
|
||||||
|
selenium-webdriver (2.41.0)
|
||||||
|
childprocess (>= 0.5.0)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
rubyzip (~> 1.0)
|
||||||
|
websocket (~> 1.0.4)
|
||||||
simplecov (0.7.1)
|
simplecov (0.7.1)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
simplecov-html (~> 0.7.1)
|
simplecov-html (~> 0.7.1)
|
||||||
|
@ -237,6 +247,7 @@ GEM
|
||||||
kgio (~> 2.6)
|
kgio (~> 2.6)
|
||||||
rack
|
rack
|
||||||
raindrops (~> 0.7)
|
raindrops (~> 0.7)
|
||||||
|
websocket (1.0.7)
|
||||||
websocket-driver (0.3.2)
|
websocket-driver (0.3.2)
|
||||||
win32console (1.3.2-x86-mingw32)
|
win32console (1.3.2-x86-mingw32)
|
||||||
xpath (2.0.0)
|
xpath (2.0.0)
|
||||||
|
@ -248,7 +259,7 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
annotate (~> 2.6.2)
|
annotate (~> 2.6.2)
|
||||||
bb-ruby (~> 1.0.4)
|
bbcoder (~> 1.0.1)
|
||||||
bluecloth (~> 2.2.0)
|
bluecloth (~> 2.2.0)
|
||||||
capistrano (~> 3.1.0)
|
capistrano (~> 3.1.0)
|
||||||
capistrano-bundler (~> 1.1.2)
|
capistrano-bundler (~> 1.1.2)
|
||||||
|
@ -260,6 +271,7 @@ DEPENDENCIES
|
||||||
codeclimate-test-reporter (~> 0.3.0)
|
codeclimate-test-reporter (~> 0.3.0)
|
||||||
coffee-rails (~> 3.2.2)
|
coffee-rails (~> 3.2.2)
|
||||||
dalli (~> 2.7.0)
|
dalli (~> 2.7.0)
|
||||||
|
database_cleaner (~> 1.2.0)
|
||||||
dotenv-rails (~> 0.10.0)
|
dotenv-rails (~> 0.10.0)
|
||||||
factory_girl_rails (~> 4.4.1)
|
factory_girl_rails (~> 4.4.1)
|
||||||
gruff (~> 0.3.6)
|
gruff (~> 0.3.6)
|
||||||
|
@ -272,11 +284,12 @@ DEPENDENCIES
|
||||||
poltergeist (~> 1.5.0)
|
poltergeist (~> 1.5.0)
|
||||||
pry-debugger (~> 0.2.2)
|
pry-debugger (~> 0.2.2)
|
||||||
rails (~> 3.2.17)
|
rails (~> 3.2.17)
|
||||||
rbbcode (~> 0.1.11)
|
|
||||||
rmagick (~> 2.13.2)
|
rmagick (~> 2.13.2)
|
||||||
rspec-given (~> 3.5.4)
|
rspec-given (~> 3.5.4)
|
||||||
rspec-rails (~> 2.14.1)
|
rspec-rails (~> 2.14.1)
|
||||||
|
sanitize (~> 2.1.0)
|
||||||
sass-rails (~> 3.2.5)
|
sass-rails (~> 3.2.5)
|
||||||
|
selenium-webdriver (~> 2.41.0)
|
||||||
simplecov (~> 0.7.1)
|
simplecov (~> 0.7.1)
|
||||||
therubyracer (~> 0.12.1)
|
therubyracer (~> 0.12.1)
|
||||||
tinymce-rails (~> 3.5.4.1)
|
tinymce-rails (~> 3.5.4.1)
|
||||||
|
|
|
@ -79,7 +79,6 @@ div
|
||||||
&[type=submit]
|
&[type=submit]
|
||||||
@include shadow
|
@include shadow
|
||||||
height: 21px
|
height: 21px
|
||||||
width: 20px
|
|
||||||
border: 1px solid #cecece
|
border: 1px solid #cecece
|
||||||
background-color: #f7f7f7
|
background-color: #f7f7f7
|
||||||
color: #3a3a3a
|
color: #3a3a3a
|
||||||
|
|
|
@ -6,9 +6,8 @@ class ArticlesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def news_index
|
def news_index
|
||||||
@cat = params[:cat] ? Category.find(params[:cat]) : Article.onlynews.ordered.first.category
|
@news = Article.with_comments.ordered.limited.nodrafts.onlynews
|
||||||
@news = Article.with_comments.ordered.limited.nodrafts.category @cat
|
@categories = Category.ordered.domain(Category::DOMAIN_NEWS)
|
||||||
@categories = Category.ordered.domain Category::DOMAIN_NEWS
|
|
||||||
@nobody = true
|
@nobody = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@ class TopicsController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
raise AccessError unless @topic.can_show? cuser
|
raise AccessError unless @topic.can_show? cuser
|
||||||
@posts = @topic.posts.basic.paginate \
|
@posts = @topic.posts.basic.paginate(:page => params[:page],
|
||||||
:page => params[:page],
|
:per_page => Topic::POSTS_PAGE)
|
||||||
:per_page => Topic::POSTS_PAGE
|
|
||||||
|
|
||||||
return_here
|
return_here
|
||||||
@topic.record_view_count(request.remote_ip, cuser.nil?)
|
@topic.record_view_count(request.remote_ip, cuser.nil?)
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
require File.join(Rails.root, 'vendor', 'plugins', 'has_view_count', 'init.rb')
|
require File.join(Rails.root, 'vendor', 'plugins', 'has_view_count', 'init.rb')
|
||||||
require 'rbbcode'
|
|
||||||
|
|
||||||
class Article < ActiveRecord::Base
|
class Article < ActiveRecord::Base
|
||||||
include Exceptions
|
include Exceptions
|
||||||
|
@ -60,7 +59,8 @@ class Article < ActiveRecord::Base
|
||||||
has_many :files, :class_name => "DataFile", :order => "created_at DESC", :dependent => :destroy
|
has_many :files, :class_name => "DataFile", :order => "created_at DESC", :dependent => :destroy
|
||||||
|
|
||||||
validates_length_of :title, :in => 1..50
|
validates_length_of :title, :in => 1..50
|
||||||
validates_length_of :text, :in => 1..64000
|
validates_length_of :text, :in => 1..16000000
|
||||||
|
|
||||||
validates_presence_of :user, :category
|
validates_presence_of :user, :category
|
||||||
validate :validate_status
|
validate :validate_status
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class Article < ActiveRecord::Base
|
||||||
|
|
||||||
def format_text
|
def format_text
|
||||||
if text_coding == CODING_BBCODE
|
if text_coding == CODING_BBCODE
|
||||||
self.text_parsed = RbbCode::Parser.new.parse(text)
|
self.text_parsed = bbcode_to_html(text)
|
||||||
elsif text_coding == CODING_MARKDOWN
|
elsif text_coding == CODING_MARKDOWN
|
||||||
self.text_parsed = BlueCloth.new(text).to_html
|
self.text_parsed = BlueCloth.new(text).to_html
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
# text_parsed :text
|
# text_parsed :text
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'rbbcode'
|
|
||||||
|
|
||||||
class Comment < ActiveRecord::Base
|
class Comment < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
|
||||||
|
@ -35,28 +33,30 @@ class Comment < ActiveRecord::Base
|
||||||
before_save :parse_text
|
before_save :parse_text
|
||||||
|
|
||||||
def parse_text
|
def parse_text
|
||||||
self.text_parsed = RbbCode::Parser.new.parse(text)
|
if self.text
|
||||||
|
self.text_parsed = bbcode_to_html(self.text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_create
|
def after_create
|
||||||
# if commentable_type == "Movie" or commentable_type == "Article" and commentable.user and commentable.user.profile.notify_own_stuff
|
# if commentable_type == "Movie" or commentable_type == "Article" and commentable.user and commentable.user.profile.notify_own_stuff
|
||||||
# Notifications.deliver_comments commentable.user, commentable
|
# Notifications.deliver_comments commentable.user, commentable
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_create? cuser
|
def can_create? cuser
|
||||||
return false unless cuser
|
return false unless cuser
|
||||||
#errors.add_to_base I18n.t(:comments_locked) if !commentable.lock.nil? and commentable.lock
|
#errors.add_to_base I18n.t(:comments_locked) if !commentable.lock.nil? and commentable.lock
|
||||||
errors.add_to_base I18n.t(:bans_mute) if cuser.banned? Ban::TYPE_MUTE
|
errors.add_to_base I18n.t(:bans_mute) if cuser.banned? Ban::TYPE_MUTE
|
||||||
errors.add_to_base I18n.t(:registered_for_week) unless cuser.verified?
|
errors.add_to_base I18n.t(:registered_for_week) unless cuser.verified?
|
||||||
return errors.count == 0
|
return errors.count == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_update? cuser
|
def can_update? cuser
|
||||||
cuser and user == cuser or cuser.admin?
|
cuser and user == cuser or cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
require File.join(Rails.root, 'vendor', 'plugins', 'acts-as-readable', 'init.rb')
|
require File.join(Rails.root, 'vendor', 'plugins', 'acts-as-readable', 'init.rb')
|
||||||
require 'rbbcode'
|
|
||||||
|
|
||||||
class Issue < ActiveRecord::Base
|
class Issue < ActiveRecord::Base
|
||||||
STATUS_OPEN = 0
|
STATUS_OPEN = 0
|
||||||
|
@ -79,7 +78,9 @@ class Issue < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_text
|
def parse_text
|
||||||
self.text_parsed = RbbCode::Parser.new.parse(text)
|
if self.text
|
||||||
|
self.text_parsed = bbcode_to_html(self.text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_readings
|
def remove_readings
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
# text_parsed :text
|
# text_parsed :text
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'rbbcode'
|
|
||||||
|
|
||||||
class Message < ActiveRecord::Base
|
class Message < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
|
||||||
|
@ -54,7 +52,9 @@ class Message < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_text
|
def parse_text
|
||||||
self.text_parsed = RbbCode::Parser.new.parse(text)
|
if self.text
|
||||||
|
self.text_parsed = bbcode_to_html(self.text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_notifications
|
def send_notifications
|
||||||
|
|
|
@ -11,81 +11,64 @@
|
||||||
# text_parsed :text
|
# text_parsed :text
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'rbbcode'
|
|
||||||
require 'bb-ruby'
|
|
||||||
|
|
||||||
class Post < ActiveRecord::Base
|
class Post < ActiveRecord::Base
|
||||||
BBCODE_DEFAULTS = {
|
include Extra
|
||||||
'Quote' => [
|
|
||||||
/\[quote(:.*)?=(.*?)\](.*?)\[\/quote\1?\]/mi,
|
|
||||||
'<fieldset class="quote"><legend>\2</legend>\3</fieldset>',
|
|
||||||
'Quote with citation',
|
|
||||||
'[quote=mike]please quote me[/quote]',
|
|
||||||
:quote
|
|
||||||
],
|
|
||||||
'Quote without author' => [
|
|
||||||
/\[quote(:.*)\](.*?)\[\/quote\1?\]/mi,
|
|
||||||
'<fieldset class="quote">\2</fieldset>',
|
|
||||||
'Quote without citation',
|
|
||||||
'[quote]please quote me[/quote]',
|
|
||||||
:quote
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
include Extra
|
attr_protected :id, :updated_at, :created_at, :votes, :user_id
|
||||||
attr_protected :id, :updated_at, :created_at, :votes, :user_id
|
|
||||||
|
|
||||||
scope :basic, :include => [{:user => [:team, :profile]}, :topic]
|
scope :basic, :include => [{:user => [:team, :profile]}, :topic]
|
||||||
|
|
||||||
validates_presence_of :topic, :user
|
validates_presence_of :topic, :user
|
||||||
validates_length_of :text, :in => 1..10000
|
validates_length_of :text, :in => 1..10000
|
||||||
|
|
||||||
before_save :parse_text
|
before_save :parse_text
|
||||||
after_create :remove_readings
|
after_create :remove_readings
|
||||||
after_destroy :remove_topics, :if => Proc.new {|post| post.topic.posts.count == 0}
|
after_destroy :remove_topics, :if => Proc.new {|post| post.topic.posts.count == 0}
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :topic
|
belongs_to :topic
|
||||||
|
|
||||||
def number pages, i
|
def number pages, i
|
||||||
if i != -1
|
if i != -1
|
||||||
pages.per_page * (pages.current_page - 1) + i + 1
|
pages.per_page * (pages.current_page - 1) + i + 1
|
||||||
else
|
else
|
||||||
topic.posts.count + 1
|
topic.posts.count + 1
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def remove_readings
|
def remove_readings
|
||||||
Reading.delete_all ["readable_type = 'Topic' AND readable_id = ?", topic.id]
|
Reading.delete_all ["readable_type = 'Topic' AND readable_id = ?", topic.id]
|
||||||
Reading.delete_all ["readable_type = 'Forum' AND readable_id = ?", topic.forum.id]
|
Reading.delete_all ["readable_type = 'Forum' AND readable_id = ?", topic.forum.id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_text
|
def parse_text
|
||||||
self.text_parsed = self.text.bbcode_to_html(BBCODE_DEFAULTS) if self.text
|
if self.text
|
||||||
|
self.text_parsed = bbcode_to_html(self.text)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def remove_topics
|
def remove_topics
|
||||||
topic.destroy
|
topic.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_messages
|
def error_messages
|
||||||
self.errors.full_messages.uniq
|
self.errors.full_messages.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_create? cuser
|
def can_create? cuser
|
||||||
return false unless cuser
|
return false unless cuser
|
||||||
errors.add :lock, I18n.t(:topics_locked) if topic.lock
|
errors.add :lock, I18n.t(:topics_locked) if topic.lock
|
||||||
errors.add :user, I18n.t(:bans_mute) if cuser.banned?(Ban::TYPE_MUTE) and topic.forum != Forum::BANS
|
errors.add :user, I18n.t(:bans_mute) if cuser.banned?(Ban::TYPE_MUTE) and topic.forum != Forum::BANS
|
||||||
errors.add :user, I18n.t(:registered_for_week) unless cuser.verified?
|
errors.add :user, I18n.t(:registered_for_week) unless cuser.verified?
|
||||||
(Forum.available_to(cuser, Forumer::ACCESS_REPLY).of_forum(topic.forum).first and errors.size == 0)
|
(Forum.available_to(cuser, Forumer::ACCESS_REPLY).of_forum(topic.forum).first and errors.size == 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_update? cuser, params = {}
|
def can_update? cuser, params = {}
|
||||||
return false unless cuser
|
return false unless cuser
|
||||||
true if Verification.contain(params, [:text, :topic_id]) and user == cuser or cuser.admin?
|
true if Verification.contain(params, [:text, :topic_id]) and user == cuser or cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_destroy? cuser
|
def can_destroy? cuser
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,8 +54,6 @@
|
||||||
# signature_parsed :string(255)
|
# signature_parsed :string(255)
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'rbbcode'
|
|
||||||
|
|
||||||
class Profile < ActiveRecord::Base
|
class Profile < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
|
||||||
|
@ -92,7 +90,7 @@ class Profile < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_text
|
def parse_text
|
||||||
self.achievements_parsed = RbbCode::Parser.new.parse(achievements) if self.achievements
|
self.achievements_parsed = bbcode_to_html(achievements) if self.achievements
|
||||||
self.signature_parsed = RbbCode::Parser.new.parse(signature) if self.signature
|
self.signature_parsed = bbcode_to_html(signature) if self.signature
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,8 +30,7 @@ class Topic < ActiveRecord::Base
|
||||||
has_many :posts, :order => "id ASC", :dependent => :destroy
|
has_many :posts, :order => "id ASC", :dependent => :destroy
|
||||||
has_many :view_counts, :as => :viewable, :dependent => :destroy
|
has_many :view_counts, :as => :viewable, :dependent => :destroy
|
||||||
|
|
||||||
scope :basic,
|
scope :basic, :include => [:latest, {:forum => :forumer}, :user]
|
||||||
:include => [:latest, {:forum => :forumer}, :user]
|
|
||||||
scope :ordered, :order => "state DESC, posts.id DESC"
|
scope :ordered, :order => "state DESC, posts.id DESC"
|
||||||
scope :recent,
|
scope :recent,
|
||||||
:conditions => "forumers.id IS NULL AND posts.id = (SELECT id FROM posts AS P WHERE P.topic_id = topics.id ORDER BY id DESC LIMIT 1)",
|
:conditions => "forumers.id IS NULL AND posts.id = (SELECT id FROM posts AS P WHERE P.topic_id = topics.id ORDER BY id DESC LIMIT 1)",
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<%= f.text_area :text, :rows => 30, :cols => 80 %>
|
<%= f.text_area :text, :rows => 30, :cols => 80 %>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<%= f.submit 'Save' %>
|
<%= f.submit %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
<%= render :partial => "data_files/list", :locals => {:files => @article.files} %>
|
<%= render :partial => "data_files/list", :locals => {:files => @article.files} %>
|
||||||
|
|
||||||
<% if @file.can_create? cuser %>
|
<% if @file && @file.can_create?(cuser) %>
|
||||||
<h3>New file</h3>
|
<h3>New file</h3>
|
||||||
|
|
||||||
<div class="wide box">
|
<div class="wide box">
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text" id="post_<%= post.id %>">
|
<td class="text" id="post_<%= post.id %>">
|
||||||
<%= raw post.text_parsed %>
|
<%= post.text_parsed.html_safe %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td id="links">
|
<td id="links">
|
||||||
<%= link_to "Register", new_user_path %> <br />
|
<%= link_to I18n.t('helpers.submit.user.create'), new_user_path %> <br />
|
||||||
<%= link_to "Forgot Password?", "/users/forgot/1" %>
|
<%= link_to I18n.t('sessions.form.forgot_password'), "/users/forgot/1" %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= text_field "login", "username" %>
|
<%= text_field "login", "username" %>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<%= password_field "login", "password" %>
|
<%= password_field "login", "password" %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= submit_tag raw("»") %>
|
<%= submit_tag I18n.t('helpers.submit.user.login') %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<% @poll = Poll.first :order => "created_at DESC" %>
|
<% @poll = Poll.first :order => "created_at DESC" %>
|
||||||
<%= render :partial => "polls/show" %>
|
<%= render(:partial => "polls/show") if @poll %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
base: &db
|
base: &db
|
||||||
adapter: mysql2
|
adapter: mysql2
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
pool: 5
|
|
||||||
host: localhost
|
host: localhost
|
||||||
database: <%= ENV['MYSQL_DATABASE'] %>
|
database: <%= ENV['MYSQL_DATABASE'] %>
|
||||||
username: <%= ENV['MYSQL_USERNAME'] %>
|
username: <%= ENV['MYSQL_USERNAME'] %>
|
||||||
password: <%= ENV['MYSQL_PASSWORD'] %>
|
password: <%= ENV['MYSQL_PASSWORD'] %>
|
||||||
|
pool: <%= Integer(ENV['MYSQL_CONNECTION_POOL'] || 8) %>
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *db
|
<<: *db
|
||||||
database: ensl_development
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
<<: *db
|
<<: *db
|
||||||
|
|
|
@ -19,7 +19,7 @@ set :unicorn_config_path, "config/unicorn.rb"
|
||||||
set :writable_dirs, %w{public tmp}
|
set :writable_dirs, %w{public tmp}
|
||||||
set :linked_files, %w{.env}
|
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/system public/local public/uploads public/files}
|
||||||
|
|
||||||
set :normalize_asset_timestamps, %{public/images
|
set :normalize_asset_timestamps, %{public/images
|
||||||
public/javascripts
|
public/javascripts
|
||||||
|
|
27
config/initializers/bbcoder.rb
Normal file
27
config/initializers/bbcoder.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
BBCoder.configure do
|
||||||
|
tag :b, :as => :strong
|
||||||
|
|
||||||
|
tag :sub, :singular => true do
|
||||||
|
%(<sub>#{singular? ? meta : content}</sub>)
|
||||||
|
end
|
||||||
|
|
||||||
|
tag :sup, :singular => true do
|
||||||
|
%(<sup>#{singular? ? meta : content}</sup>)
|
||||||
|
end
|
||||||
|
|
||||||
|
tag :ul
|
||||||
|
tag :ol
|
||||||
|
tag :li, :parents => [:ol, :ul]
|
||||||
|
|
||||||
|
tag :size do
|
||||||
|
%(<span style="font-size: #{meta}px;">#{content}</span>)
|
||||||
|
end
|
||||||
|
|
||||||
|
tag :url do
|
||||||
|
if meta.nil? || meta.empty?
|
||||||
|
%(<a href="#{content}">#{content}</a>)
|
||||||
|
else
|
||||||
|
%(<a href="#{meta}">#{content}</a>)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -81,15 +81,23 @@ en:
|
||||||
votes_success: "Voted successfully."
|
votes_success: "Voted successfully."
|
||||||
error: "error"
|
error: "error"
|
||||||
prohibited: "prohibited"
|
prohibited: "prohibited"
|
||||||
|
sessions:
|
||||||
|
form:
|
||||||
|
forgot_password: "Forgot password?"
|
||||||
errors:
|
errors:
|
||||||
template:
|
template:
|
||||||
header: "Please review the following errors:"
|
header: "Please review the following errors:"
|
||||||
helpers:
|
helpers:
|
||||||
submit:
|
submit:
|
||||||
user:
|
user:
|
||||||
|
login: "Login"
|
||||||
create: "Register"
|
create: "Register"
|
||||||
|
post:
|
||||||
|
create: "Create Article"
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
|
article:
|
||||||
|
title: "Title"
|
||||||
user:
|
user:
|
||||||
username: "Username"
|
username: "Username"
|
||||||
email: "Email"
|
email: "Email"
|
||||||
|
|
|
@ -15,7 +15,7 @@ common: &default_settings
|
||||||
# You must specify the license key associated with your New Relic
|
# You must specify the license key associated with your New Relic
|
||||||
# account. This key binds your Agent's data to your account in the
|
# account. This key binds your Agent's data to your account in the
|
||||||
# New Relic service.
|
# New Relic service.
|
||||||
license_key: '<%= license_key %>'
|
license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
|
||||||
|
|
||||||
# Agent Enabled (Ruby/Rails Only)
|
# Agent Enabled (Ruby/Rails Only)
|
||||||
# Use this setting to force the agent to run or not run.
|
# Use this setting to force the agent to run or not run.
|
||||||
|
@ -42,7 +42,7 @@ common: &default_settings
|
||||||
# - Ajax Service
|
# - Ajax Service
|
||||||
# - All Services
|
# - All Services
|
||||||
#
|
#
|
||||||
app_name: <%= @app_name %>
|
app_name: <%= ENV['NEW_RELIC_APP_NAME'] %>
|
||||||
|
|
||||||
# When "true", the agent collects performance data about your
|
# When "true", the agent collects performance data about your
|
||||||
# application and reports this data to the New Relic service at
|
# application and reports this data to the New Relic service at
|
||||||
|
@ -190,7 +190,7 @@ development:
|
||||||
<<: *default_settings
|
<<: *default_settings
|
||||||
# Turn on communication to New Relic service in development mode
|
# Turn on communication to New Relic service in development mode
|
||||||
monitor_mode: true
|
monitor_mode: true
|
||||||
app_name: <%= @app_name %> (Development)
|
app_name: <%= ENV['NEW_RELIC_APP_NAME'] %> (Development)
|
||||||
|
|
||||||
# Rails Only - when running in Developer Mode, the New Relic Agent will
|
# Rails Only - when running in Developer Mode, the New Relic Agent will
|
||||||
# present performance information on the last 100 transactions you have
|
# present performance information on the last 100 transactions you have
|
||||||
|
@ -222,4 +222,4 @@ production:
|
||||||
staging:
|
staging:
|
||||||
<<: *default_settings
|
<<: *default_settings
|
||||||
monitor_mode: true
|
monitor_mode: true
|
||||||
app_name: <%= @app_name %> (Staging)
|
app_name: <%= ENV['NEW_RELIC_APP_NAME'] %> (Staging)
|
||||||
|
|
17
db/migrate/20140330152235_increase_article_text_limit.rb
Normal file
17
db/migrate/20140330152235_increase_article_text_limit.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class IncreaseArticleTextLimit < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
change_column :articles, :text, :text, :limit => 16777215
|
||||||
|
change_column :articles, :text_parsed, :text, :limit => 16777215
|
||||||
|
|
||||||
|
change_column :article_versions, :text, :text, :limit => 16777215
|
||||||
|
change_column :article_versions, :text_parsed, :text, :limit => 16777215
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_column :articles, :text, :text, :limit => 65535
|
||||||
|
change_column :articles, :text_parsed, :text, :limit => 65535
|
||||||
|
|
||||||
|
change_column :article_versions, :text, :text, :limit => 65535
|
||||||
|
change_column :article_versions, :text_parsed, :text, :limit => 65535
|
||||||
|
end
|
||||||
|
end
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20120122001951) do
|
ActiveRecord::Schema.define(:version => 20140330152235) do
|
||||||
|
|
||||||
create_table "admin_requests", :force => true do |t|
|
create_table "admin_requests", :force => true do |t|
|
||||||
t.string "addr"
|
t.string "addr"
|
||||||
|
@ -31,26 +31,26 @@ ActiveRecord::Schema.define(:version => 20120122001951) do
|
||||||
t.integer "article_id"
|
t.integer "article_id"
|
||||||
t.integer "version"
|
t.integer "version"
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.text "text"
|
t.text "text", :limit => 16777215
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.text "text_parsed"
|
t.text "text_parsed", :limit => 16777215
|
||||||
t.integer "text_coding", :default => 0, :null => false
|
t.integer "text_coding", :default => 0, :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "article_versions", ["article_id"], :name => "index_article_versions_on_article_id"
|
add_index "article_versions", ["article_id"], :name => "index_article_versions_on_article_id"
|
||||||
|
|
||||||
create_table "articles", :force => true do |t|
|
create_table "articles", :force => true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.integer "status", :null => false
|
t.integer "status", :null => false
|
||||||
t.integer "category_id"
|
t.integer "category_id"
|
||||||
t.text "text"
|
t.text "text", :limit => 16777215
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "version"
|
t.integer "version"
|
||||||
t.text "text_parsed"
|
t.text "text_parsed", :limit => 16777215
|
||||||
t.integer "text_coding", :default => 0, :null => false
|
t.integer "text_coding", :default => 0, :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "articles", ["category_id"], :name => "index_articles_on_category_id"
|
add_index "articles", ["category_id"], :name => "index_articles_on_category_id"
|
||||||
|
|
|
@ -18,6 +18,10 @@ module Extra
|
||||||
{CODING_HTML => "Plain HTML", CODING_BBCODE => "BBCode", CODING_MARKDOWN => "Markdown"}
|
{CODING_HTML => "Plain HTML", CODING_BBCODE => "BBCode", CODING_MARKDOWN => "Markdown"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bbcode_to_html(text)
|
||||||
|
Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\n|\r\n/, "<br />").html_safe
|
||||||
|
end
|
||||||
|
|
||||||
def move_up scope, column = "position"
|
def move_up scope, column = "position"
|
||||||
n = 0
|
n = 0
|
||||||
objects = self.class.all :conditions => scope, :order => column
|
objects = self.class.all :conditions => scope, :order => column
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
sequence :title do |n|
|
|
||||||
"Article #{n}"
|
|
||||||
end
|
|
||||||
|
|
||||||
sequence :text do |n|
|
|
||||||
(0..100).map{ (0...8).map { (65 + rand(26)).chr }.join }.join(" ")
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :article do
|
factory :article do
|
||||||
title
|
sequence(:title) { |n| "Article #{n}" }
|
||||||
text
|
sequence(:text) { |n| (0..100).map{ (0...8).map { (65 + rand(26)).chr }.join }.join(" ") }
|
||||||
end
|
end
|
||||||
end
|
end
|
6
spec/factories/category.rb
Normal file
6
spec/factories/category.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :category do
|
||||||
|
sequence(:name) { |n| "Category #{n}" }
|
||||||
|
sequence(:sort) { |n| n }
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,10 +1,7 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
sequence :name do |n|
|
|
||||||
"Team ##{n}"
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :team do
|
factory :team do
|
||||||
name
|
sequence(:name) { |n| "Team ##{n}" }
|
||||||
|
|
||||||
irc "#team"
|
irc "#team"
|
||||||
web "http://team.com"
|
web "http://team.com"
|
||||||
tag "[TEAM]"
|
tag "[TEAM]"
|
||||||
|
|
|
@ -1,20 +1,9 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
sequence :username do |n|
|
|
||||||
"Player#{n}"
|
|
||||||
end
|
|
||||||
|
|
||||||
sequence :email do |n|
|
|
||||||
"player#{n}@ensl.org"
|
|
||||||
end
|
|
||||||
|
|
||||||
sequence :steamid do |n|
|
|
||||||
"0:1:#{n}"
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :user do
|
factory :user do
|
||||||
username
|
sequence(:username) { |n| "Player#{n}" }
|
||||||
email
|
sequence(:email) { |n| "player#{n}@ensl.org" }
|
||||||
steamid
|
sequence(:steamid) { |n| "0:1:#{n}" }
|
||||||
|
|
||||||
firstname "ENSL"
|
firstname "ENSL"
|
||||||
lastname "Player"
|
lastname "Player"
|
||||||
country "EU"
|
country "EU"
|
||||||
|
|
|
@ -1,14 +1,39 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature 'User creates new article' do
|
feature 'User creates new article' do
|
||||||
let(:user) { create(:user) }
|
let!(:category) { create(:category, domain: Category::DOMAIN_NEWS) }
|
||||||
let(:article) { attributes_for(:article) }
|
let(:article) { attributes_for(:article) }
|
||||||
|
|
||||||
before do
|
describe 'with valid Title, Content, Category' do
|
||||||
visit new_article_path
|
context 'as a basic user' do
|
||||||
|
let!(:user) { create(:user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in_as(user)
|
||||||
|
visit new_article_path
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates an article successfully' do
|
||||||
|
fill_in attribute_translation(:article, :title), with: article[:title]
|
||||||
|
fill_tinymce "#article_text", article[:text]
|
||||||
|
click_button I18n.t('helpers.submit.post.create')
|
||||||
|
|
||||||
|
expect(page).to have_content(I18n.t('articles_create'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates an article with a text length greater than 65535 bytes' do
|
||||||
|
fill_in attribute_translation(:article, :title), with: article[:title]
|
||||||
|
fill_tinymce "#article_text", long_text
|
||||||
|
click_button I18n.t('helpers.submit.post.create')
|
||||||
|
|
||||||
|
expect(page).to have_content(I18n.t('articles_create'))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with valid Title, Content: ' do
|
private
|
||||||
describe ''
|
|
||||||
|
def long_text
|
||||||
|
(0..10000).map{ (0...8).map { (65 + rand(26)).chr }.join }.join(" ") # 90008
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,15 +10,29 @@ require 'rspec/rails'
|
||||||
require 'capybara/rspec'
|
require 'capybara/rspec'
|
||||||
require 'capybara/poltergeist'
|
require 'capybara/poltergeist'
|
||||||
|
|
||||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
Capybara.register_driver :poltergeist do |app|
|
||||||
|
Capybara::Poltergeist::Driver.new(app, :phantomjs_logger => File.open('/dev/null'))
|
||||||
|
end
|
||||||
|
|
||||||
Capybara.javascript_driver = :poltergeist
|
Capybara.javascript_driver = :poltergeist
|
||||||
|
|
||||||
|
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include FactoryGirl::Syntax::Methods
|
config.include FactoryGirl::Syntax::Methods
|
||||||
config.include Controllers::JsonHelpers, :type => :controller
|
config.include Controllers::JsonHelpers, type: :controller
|
||||||
|
config.include Features::FormHelpers, type: :feature
|
||||||
|
config.include Features::SessionHelpers, type: :feature
|
||||||
|
|
||||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||||
config.use_transactional_fixtures = true
|
config.order = 'random'
|
||||||
config.order = "random"
|
config.use_transactional_fixtures = false
|
||||||
|
|
||||||
|
config.before(:each) do
|
||||||
|
if example.metadata[:type] == :feature
|
||||||
|
Capybara.current_driver = :poltergeist
|
||||||
|
else
|
||||||
|
Capybara.use_default_driver
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
21
spec/support/database_cleaner.rb
Normal file
21
spec/support/database_cleaner.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.before(:suite) do
|
||||||
|
DatabaseCleaner.clean_with(:deletion)
|
||||||
|
end
|
||||||
|
|
||||||
|
config.before(:each) do
|
||||||
|
DatabaseCleaner.strategy = :deletion
|
||||||
|
end
|
||||||
|
|
||||||
|
config.before(:each, js: true) do
|
||||||
|
DatabaseCleaner.strategy = :deletion
|
||||||
|
end
|
||||||
|
|
||||||
|
config.before(:each) do
|
||||||
|
DatabaseCleaner.start
|
||||||
|
end
|
||||||
|
|
||||||
|
config.after(:each) do
|
||||||
|
DatabaseCleaner.clean
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,4 +0,0 @@
|
||||||
RSpec.configure do |config|
|
|
||||||
config.include Features::FormHelpers, type: :feature
|
|
||||||
config.include Features::SessionHelpers, type: :feature
|
|
||||||
end
|
|
|
@ -6,12 +6,14 @@ module Features
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fill_tinymce(element, contents)
|
||||||
|
page.execute_script("$('#{element}').tinymce().setContent('#{contents}')")
|
||||||
|
end
|
||||||
|
|
||||||
def submit(model, action)
|
def submit(model, action)
|
||||||
helper_translation(model, action)
|
helper_translation(model, action)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def attribute_translation(model, attribute)
|
def attribute_translation(model, attribute)
|
||||||
I18n.t("activerecord.attributes.#{model}.#{attribute}")
|
I18n.t("activerecord.attributes.#{model}.#{attribute}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
module Features
|
module Features
|
||||||
module SessionHelpers
|
module SessionHelpers
|
||||||
def sign_in
|
def sign_in_as(user)
|
||||||
visit root_path
|
visit root_path
|
||||||
user = create(:user)
|
|
||||||
fill_form(:user, { email: user.email, password: user.raw_password })
|
fill_in "login_username", with: user.username
|
||||||
click_button '»'
|
fill_in "login_password", with: user.raw_password
|
||||||
|
|
||||||
|
click_button 'Login'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue