mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 13:21:29 +00:00
More work on feature tests, remove readings
This commit is contained in:
parent
9952bf52b5
commit
a6eb8bc7b1
14 changed files with 55 additions and 51 deletions
|
@ -1,8 +1,11 @@
|
||||||
# Development
|
# Development
|
||||||
|
|
||||||
Currently buggy.
|
This is just random tips for development. Not a full documentation.
|
||||||
|
|
||||||
# Handy commands
|
# Handy commands
|
||||||
|
|
||||||
`docker-compose -f docker-compose.dev.yml exec -u web web /bin/bash`
|
`docker-compose -f docker-compose.dev.yml exec -u web web /bin/bash`
|
||||||
`docker-compose -f docker-compose.dev.yml restart web`
|
`docker-compose -f docker-compose.dev.yml exec -u web test /bin/bash`
|
||||||
|
`docker-compose -f docker-compose.dev.yml restart web`
|
||||||
|
`docker-compose -f docker-compose.dev.yml exec -u web test bundle exec rspec`
|
||||||
|
`docker-compose -f docker-compose.dev.yml exec -u web test bundle exec rspec spec/controllers/shoutmsgs_controller_spec.rb`
|
|
@ -6,9 +6,14 @@ ENV RAILS_ENV development
|
||||||
RUN adduser web --home /home/web --shell /bin/bash --disabled-password --gecos ""
|
RUN adduser web --home /home/web --shell /bin/bash --disabled-password --gecos ""
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y upgrade \
|
RUN apt-get update && apt-get -y upgrade \
|
||||||
&& apt-get -y install libmariadb-dev libmariadb-dev-compat nodejs \
|
&& apt-get -y install \
|
||||||
zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev \
|
libmariadb-dev libmariadb-dev-compat \
|
||||||
libxslt1-dev imagemagick libmagickwand-dev
|
libssl-dev \
|
||||||
|
zlib1g-dev libreadline-dev libyaml-dev \
|
||||||
|
libxslt1-dev libxml2-dev \
|
||||||
|
imagemagick libmagickwand-dev \
|
||||||
|
nodejs \
|
||||||
|
firefox-esr
|
||||||
|
|
||||||
# Separate Gemfile ADD so that `bundle install` can be cached more effectively
|
# Separate Gemfile ADD so that `bundle install` can be cached more effectively
|
||||||
ADD Gemfile Gemfile.lock /var/www/
|
ADD Gemfile Gemfile.lock /var/www/
|
||||||
|
|
13
Gemfile
13
Gemfile
|
@ -77,17 +77,18 @@ end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
# gem 'spring'
|
# gem 'spring'
|
||||||
gem 'simplecov', '~> 0.7.1', require: false
|
gem 'rspec'
|
||||||
gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil
|
|
||||||
gem 'database_cleaner', '~> 1.2.0'
|
|
||||||
gem 'rspec-rails', '~> 3.3.3'
|
gem 'rspec-rails', '~> 3.3.3'
|
||||||
|
gem 'factory_bot_rails'
|
||||||
|
gem 'database_cleaner', '~> 1.2.0'
|
||||||
gem 'capybara', '~> 2.4.4'
|
gem 'capybara', '~> 2.4.4'
|
||||||
gem 'poltergeist', '~> 1.6.0'
|
gem 'poltergeist', '~> 1.6.0'
|
||||||
gem 'selenium-webdriver', '~> 2.47.1'
|
gem 'selenium-webdriver'
|
||||||
gem 'factory_bot_rails'
|
|
||||||
gem 'timecop', '~> 0.7.1'
|
gem 'timecop', '~> 0.7.1'
|
||||||
gem 'rspec'
|
gem 'simplecov', '~> 0.7.1', require: false
|
||||||
|
gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil
|
||||||
gem 'test-unit', '~> 3.1.3'
|
gem 'test-unit', '~> 3.1.3'
|
||||||
|
gem 'phantomjs', :require => 'phantomjs/poltergeist'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|
|
@ -183,6 +183,7 @@ GEM
|
||||||
nokogiri (1.9.1)
|
nokogiri (1.9.1)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
os (0.9.6)
|
os (0.9.6)
|
||||||
|
phantomjs (2.1.1.0)
|
||||||
poltergeist (1.6.0)
|
poltergeist (1.6.0)
|
||||||
capybara (~> 2.1)
|
capybara (~> 2.1)
|
||||||
cliver (~> 0.3.1)
|
cliver (~> 0.3.1)
|
||||||
|
@ -354,6 +355,7 @@ DEPENDENCIES
|
||||||
neat (~> 1.6.0)
|
neat (~> 1.6.0)
|
||||||
newrelic_rpm (~> 3.13.0.299)
|
newrelic_rpm (~> 3.13.0.299)
|
||||||
nokogiri (~> 1.9.0)
|
nokogiri (~> 1.9.0)
|
||||||
|
phantomjs
|
||||||
poltergeist (~> 1.6.0)
|
poltergeist (~> 1.6.0)
|
||||||
protected_attributes (~> 1.1.3)
|
protected_attributes (~> 1.1.3)
|
||||||
pry-byebug (~> 1.3.2)
|
pry-byebug (~> 1.3.2)
|
||||||
|
@ -368,7 +370,7 @@ DEPENDENCIES
|
||||||
rspec-rails (~> 3.3.3)
|
rspec-rails (~> 3.3.3)
|
||||||
sanitize (~> 2.1.0)
|
sanitize (~> 2.1.0)
|
||||||
sass-rails (~> 5.0.3)
|
sass-rails (~> 5.0.3)
|
||||||
selenium-webdriver (~> 2.47.1)
|
selenium-webdriver
|
||||||
signet (= 0.11.0)
|
signet (= 0.11.0)
|
||||||
simplecov (~> 0.7.1)
|
simplecov (~> 0.7.1)
|
||||||
steam-condenser!
|
steam-condenser!
|
||||||
|
|
|
@ -2,7 +2,7 @@ class ShoutmsgsController < ApplicationController
|
||||||
respond_to :html, :js
|
respond_to :html, :js
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@shoutmsgs = Shoutmsg.last.typebox
|
@shoutmsgs = Shoutmsg.typebox
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -66,7 +66,6 @@ class Article < ActiveRecord::Base
|
||||||
before_validation :init_variables, :if => Proc.new{ |model| model.new_record? }
|
before_validation :init_variables, :if => Proc.new{ |model| model.new_record? }
|
||||||
before_save :format_text
|
before_save :format_text
|
||||||
after_save :send_notifications
|
after_save :send_notifications
|
||||||
after_destroy :remove_readings
|
|
||||||
|
|
||||||
has_view_count
|
has_view_count
|
||||||
acts_as_readable
|
acts_as_readable
|
||||||
|
|
|
@ -49,20 +49,19 @@ class Challenge < ActiveRecord::Base
|
||||||
#validate_on_update :validate_map2
|
#validate_on_update :validate_map2
|
||||||
#validate_on_update :validate_status
|
#validate_on_update :validate_status
|
||||||
|
|
||||||
scope :of_contester,
|
scope :category, -> (cat) { where(category_id: cat) }
|
||||||
lambda { |contester| {:conditions => ["contester1_id = ? OR contester2_id = ?", contester.id, contester.id]} }
|
|
||||||
scope :within_time,
|
scope :of_contester, -> (contester) { where("contester1_id = ? OR contester2_id = ?", contester.id, contester.id) }
|
||||||
lambda { |from, to| {:conditions => ["match_time > ? AND match_time < ?", from.utc, to.utc]} }
|
scope :within_time, -> (from, to) { where("match_time > ? AND match_time < ?", from.utc, to.utc) }
|
||||||
scope :around,
|
scope :around, -> (time) { where("match_time > ? AND match_time < ?", time.ago(MATCH_LENGTH).utc, time.ago(-MATCH_LENGTH).utc) }
|
||||||
lambda { |time| {:conditions => ["match_time > ? AND match_time < ?", time.ago(MATCH_LENGTH).utc, time.ago(-MATCH_LENGTH).utc]} }
|
scope :on_week, -> (time) { where("match_time > ? and match_time < ?", time.beginning_of_week, time.end_of_week) }
|
||||||
scope :on_week,
|
scope :pending, -> { where(status: STATUS_PENDING) }
|
||||||
lambda { |time| {:conditions => ["match_time > ? and match_time < ?", time.beginning_of_week, time.end_of_week]} }
|
scope :mandatory, -> { where(mandatory: true) }
|
||||||
scope :pending, :conditions => {:status => STATUS_PENDING}
|
scope :future, -> { where("match_time > UTC_TIMESTAMP()") }
|
||||||
scope :mandatory, :conditions => {:mandatory => true}
|
scope :past, -> { where("match_time < UTC_TIMESTAMP()") }
|
||||||
scope :future, :conditions => "match_time > UTC_TIMESTAMP()"
|
|
||||||
scope :past, :conditions => "match_time < UTC_TIMESTAMP()"
|
|
||||||
|
|
||||||
has_one :match
|
has_one :match
|
||||||
|
|
||||||
belongs_to :map1, :class_name => "Map"
|
belongs_to :map1, :class_name => "Map"
|
||||||
belongs_to :map2, :class_name => "Map"
|
belongs_to :map2, :class_name => "Map"
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
|
@ -92,13 +92,6 @@ class Issue < ActiveRecord::Base
|
||||||
bbcode_to_html(solution)
|
bbcode_to_html(solution)
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME
|
|
||||||
def remove_readings
|
|
||||||
if status_changed? and status == STATUS_SOLVED
|
|
||||||
Reading.delete_all ["readable_type = 'Issue' AND readable_id = ?", self.id]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def can_show? cuser
|
def can_show? cuser
|
||||||
return false unless cuser
|
return false unless cuser
|
||||||
return true if cuser.admin?
|
return true if cuser.admin?
|
||||||
|
|
|
@ -22,7 +22,6 @@ class Post < ActiveRecord::Base
|
||||||
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_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
|
||||||
|
@ -35,13 +34,7 @@ class Post < ActiveRecord::Base
|
||||||
topic.posts.count + 1
|
topic.posts.count + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME
|
|
||||||
def remove_readings
|
|
||||||
Reading.delete_all ["readable_type = 'Topic' AND readable_id = ?", topic.id]
|
|
||||||
Reading.delete_all ["readable_type = 'Forum' AND readable_id = ?", topic.forum.id]
|
|
||||||
end
|
|
||||||
|
|
||||||
def parse_text
|
def parse_text
|
||||||
if self.text
|
if self.text
|
||||||
self.text_parsed = bbcode_to_html(self.text)
|
self.text_parsed = bbcode_to_html(self.text)
|
||||||
|
|
|
@ -224,9 +224,9 @@
|
||||||
<%= render partial: "issues/list", locals: { issues: @user.issues } %>
|
<%= render partial: "issues/list", locals: { issues: @user.issues } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @user.asssigned_issues.size > 0 %>
|
<% if @user.assigned_issues.size > 0 %>
|
||||||
<h4>Open issues assigned to you</h4>
|
<h4>Open issues assigned to you</h4>
|
||||||
<%= render partial: "issues/list", locals: { issues: @user.asssigned_issues } %>
|
<%= render partial: "issues/list", locals: { issues: @user.assigned_issues } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= link_to 'New issue', new_issue_path, class: 'button' %>
|
<%= link_to 'New issue', new_issue_path, class: 'button' %>
|
||||||
|
|
|
@ -36,7 +36,7 @@ Ensl::Application.routes.draw do
|
||||||
get 'comments/quote'
|
get 'comments/quote'
|
||||||
|
|
||||||
resources :comments
|
resources :comments
|
||||||
resources :shoutmsgs, except: :index
|
resources :shoutmsgs
|
||||||
resources :teamers
|
resources :teamers
|
||||||
resources :teams
|
resources :teams
|
||||||
resources :gathers
|
resources :gathers
|
||||||
|
|
|
@ -19,7 +19,7 @@ services:
|
||||||
links:
|
links:
|
||||||
- db
|
- db
|
||||||
- memcached
|
- memcached
|
||||||
- selenium
|
#- selenium
|
||||||
#- redis
|
#- redis
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
@ -58,6 +58,7 @@ services:
|
||||||
image: selenium/standalone-chrome-debug
|
image: selenium/standalone-chrome-debug
|
||||||
ports:
|
ports:
|
||||||
- 5900:5900
|
- 5900:5900
|
||||||
|
- 4444:4444
|
||||||
|
|
||||||
db:
|
db:
|
||||||
# Debug
|
# Debug
|
||||||
|
|
3
spec/controllers/users_controller_spec.rb
Normal file
3
spec/controllers/users_controller_spec.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
RSpec.describe UsersController, type: :controller do
|
||||||
|
|
||||||
|
end
|
|
@ -11,17 +11,20 @@ SimpleCov.start "rails"
|
||||||
require File.expand_path("../../config/environment", __FILE__)
|
require File.expand_path("../../config/environment", __FILE__)
|
||||||
require "rspec/rails"
|
require "rspec/rails"
|
||||||
require "capybara/rspec"
|
require "capybara/rspec"
|
||||||
require "capybara/poltergeist"
|
|
||||||
|
|
||||||
|
require "capybara/poltergeist"
|
||||||
Capybara.default_wait_time = 5
|
Capybara.default_wait_time = 5
|
||||||
Capybara.register_driver :poltergeist do |app|
|
Capybara.register_driver :poltergeist do |app|
|
||||||
Capybara::Poltergeist::Driver.new(
|
Capybara::Poltergeist::Driver.new(
|
||||||
app,
|
app,
|
||||||
timeout: 30,
|
timeout: 30,
|
||||||
phantomjs_logger: File.open("/dev/null")
|
# phantomjs_logger: File.open("/dev/null"),
|
||||||
|
phantomjs: Phantomjs.path
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Capybara.javascript_driver = :poltergeist
|
||||||
|
|
||||||
SELENIUM_HOST = ENV['SELENIUM_HOST']
|
SELENIUM_HOST = ENV['SELENIUM_HOST']
|
||||||
TEST_APP_HOST = ENV['TEST_APP_HOST']
|
TEST_APP_HOST = ENV['TEST_APP_HOST']
|
||||||
TEST_APP_PORT = ENV['TEST_APP_PORT']
|
TEST_APP_PORT = ENV['TEST_APP_PORT']
|
||||||
|
@ -35,10 +38,12 @@ Capybara.register_driver :selenium_remote do |app|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.javascript_driver = :selenium_remote
|
#Capybara.javascript_driver = :selenium_remote
|
||||||
Capybara.server_port = TEST_APP_PORT
|
|
||||||
Capybara.server_host = '0.0.0.0'
|
#Capybara.javascript_driver = :selenium_remote
|
||||||
Capybara.app_host = "http://#{TEST_APP_HOST}:#{TEST_APP_PORT}"
|
#Capybara.server_port = TEST_APP_PORT
|
||||||
|
#Capybara.server_host = '0.0.0.0'
|
||||||
|
#Capybara.app_host = "http://#{TEST_APP_HOST}:#{TEST_APP_PORT}"
|
||||||
|
|
||||||
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
||||||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||||
|
|
Loading…
Reference in a new issue