diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 212a40c..01e52c6 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -1,8 +1,11 @@ # Development -Currently buggy. +This is just random tips for development. Not a full documentation. # Handy commands `docker-compose -f docker-compose.dev.yml exec -u web web /bin/bash` -`docker-compose -f docker-compose.dev.yml restart web` \ No newline at end of file +`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` \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev index 64f720e..c1d05fe 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -6,9 +6,14 @@ ENV RAILS_ENV development RUN adduser web --home /home/web --shell /bin/bash --disabled-password --gecos "" RUN apt-get update && apt-get -y upgrade \ - && apt-get -y install libmariadb-dev libmariadb-dev-compat nodejs \ - zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev \ - libxslt1-dev imagemagick libmagickwand-dev + && apt-get -y install \ + libmariadb-dev libmariadb-dev-compat \ + 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 ADD Gemfile Gemfile.lock /var/www/ diff --git a/Gemfile b/Gemfile index 28bf85b..61fa73b 100644 --- a/Gemfile +++ b/Gemfile @@ -77,17 +77,18 @@ end group :test do # gem 'spring' - gem 'simplecov', '~> 0.7.1', require: false - gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil - gem 'database_cleaner', '~> 1.2.0' + gem 'rspec' gem 'rspec-rails', '~> 3.3.3' + gem 'factory_bot_rails' + gem 'database_cleaner', '~> 1.2.0' gem 'capybara', '~> 2.4.4' gem 'poltergeist', '~> 1.6.0' - gem 'selenium-webdriver', '~> 2.47.1' - gem 'factory_bot_rails' + gem 'selenium-webdriver' 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 'phantomjs', :require => 'phantomjs/poltergeist' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index ad1189c..3a10431 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -183,6 +183,7 @@ GEM nokogiri (1.9.1) mini_portile2 (~> 2.4.0) os (0.9.6) + phantomjs (2.1.1.0) poltergeist (1.6.0) capybara (~> 2.1) cliver (~> 0.3.1) @@ -354,6 +355,7 @@ DEPENDENCIES neat (~> 1.6.0) newrelic_rpm (~> 3.13.0.299) nokogiri (~> 1.9.0) + phantomjs poltergeist (~> 1.6.0) protected_attributes (~> 1.1.3) pry-byebug (~> 1.3.2) @@ -368,7 +370,7 @@ DEPENDENCIES rspec-rails (~> 3.3.3) sanitize (~> 2.1.0) sass-rails (~> 5.0.3) - selenium-webdriver (~> 2.47.1) + selenium-webdriver signet (= 0.11.0) simplecov (~> 0.7.1) steam-condenser! diff --git a/app/controllers/shoutmsgs_controller.rb b/app/controllers/shoutmsgs_controller.rb index 5ca3e36..e381842 100644 --- a/app/controllers/shoutmsgs_controller.rb +++ b/app/controllers/shoutmsgs_controller.rb @@ -2,7 +2,7 @@ class ShoutmsgsController < ApplicationController respond_to :html, :js def index - @shoutmsgs = Shoutmsg.last.typebox + @shoutmsgs = Shoutmsg.typebox end def show diff --git a/app/models/article.rb b/app/models/article.rb index 60791f7..b34c1da 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -66,7 +66,6 @@ class Article < ActiveRecord::Base before_validation :init_variables, :if => Proc.new{ |model| model.new_record? } before_save :format_text after_save :send_notifications - after_destroy :remove_readings has_view_count acts_as_readable diff --git a/app/models/challenge.rb b/app/models/challenge.rb index f0bb1ef..a7a6e72 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -49,20 +49,19 @@ class Challenge < ActiveRecord::Base #validate_on_update :validate_map2 #validate_on_update :validate_status - scope :of_contester, - lambda { |contester| {:conditions => ["contester1_id = ? OR contester2_id = ?", contester.id, contester.id]} } - scope :within_time, - lambda { |from, to| {:conditions => ["match_time > ? AND match_time < ?", from.utc, to.utc]} } - scope :around, - lambda { |time| {:conditions => ["match_time > ? AND match_time < ?", time.ago(MATCH_LENGTH).utc, time.ago(-MATCH_LENGTH).utc]} } - scope :on_week, - lambda { |time| {:conditions => ["match_time > ? and match_time < ?", time.beginning_of_week, time.end_of_week]} } - scope :pending, :conditions => {:status => STATUS_PENDING} - scope :mandatory, :conditions => {:mandatory => true} - scope :future, :conditions => "match_time > UTC_TIMESTAMP()" - scope :past, :conditions => "match_time < UTC_TIMESTAMP()" + scope :category, -> (cat) { where(category_id: cat) } + + scope :of_contester, -> (contester) { where("contester1_id = ? OR contester2_id = ?", contester.id, contester.id) } + scope :within_time, -> (from, to) { where("match_time > ? AND match_time < ?", from.utc, to.utc) } + scope :around, -> (time) { where("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 :pending, -> { where(status: STATUS_PENDING) } + scope :mandatory, -> { where(mandatory: true) } + scope :future, -> { where("match_time > UTC_TIMESTAMP()") } + scope :past, -> { where("match_time < UTC_TIMESTAMP()") } has_one :match + belongs_to :map1, :class_name => "Map" belongs_to :map2, :class_name => "Map" belongs_to :user diff --git a/app/models/issue.rb b/app/models/issue.rb index a3ab281..51c7a70 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -92,13 +92,6 @@ class Issue < ActiveRecord::Base bbcode_to_html(solution) 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 return false unless cuser return true if cuser.admin? diff --git a/app/models/post.rb b/app/models/post.rb index 701f8c3..360e6ad 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -22,7 +22,6 @@ class Post < ActiveRecord::Base validates_length_of :text, :in => 1..10000 before_save :parse_text - after_create :remove_readings after_destroy :remove_topics, :if => Proc.new {|post| post.topic.posts.count == 0} belongs_to :user @@ -35,13 +34,7 @@ class Post < ActiveRecord::Base topic.posts.count + 1 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 if self.text self.text_parsed = bbcode_to_html(self.text) diff --git a/app/views/users/agenda.html.erb b/app/views/users/agenda.html.erb index ffce569..eaefba0 100644 --- a/app/views/users/agenda.html.erb +++ b/app/views/users/agenda.html.erb @@ -224,9 +224,9 @@ <%= render partial: "issues/list", locals: { issues: @user.issues } %> <% end %> - <% if @user.asssigned_issues.size > 0 %> + <% if @user.assigned_issues.size > 0 %>