mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Make tests work a bit more
This commit is contained in:
parent
bb08000f1e
commit
8760116bef
7 changed files with 38 additions and 8 deletions
|
@ -6,7 +6,7 @@ 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 mysql-client libmysqlclient-dev memcached nodejs \
|
||||
&& apt-get -y install mysql-client libmysqlclient-dev memcached nodejs firefox-esr \
|
||||
&& service memcached start
|
||||
|
||||
# Separate Gemfile ADD so that `bundle install` can be cached more effectively
|
||||
|
|
|
@ -55,11 +55,7 @@ class Group < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.admins
|
||||
admins = []
|
||||
(find(ADMINS).groupers).each do |g|
|
||||
admins << g unless admins.include? g
|
||||
end
|
||||
admins
|
||||
find(ADMINS).groupers.valid_users
|
||||
end
|
||||
|
||||
def self.referees
|
||||
|
|
|
@ -21,6 +21,8 @@ class Grouper < ActiveRecord::Base
|
|||
validates :group, :user, :presence => true
|
||||
validates :task, :length => {:maximum => 25}
|
||||
|
||||
scope :valid_users, -> { joins(:user).where.not(users: { id: nil }) }
|
||||
|
||||
before_validation :fetch_user, :if => Proc.new {|grouper| grouper.username and !grouper.username.empty?}
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</tr>
|
||||
<% Group.admins.each do |grouper| %>
|
||||
<tr>
|
||||
<td class="country"><%= flag grouper.user.country %></td>
|
||||
<td class="country"><%= flag grouper.user.country_s %></td>
|
||||
<td class="username"><%= namelink grouper.user %></td>
|
||||
<td><%= h grouper.user.email_s %></td>
|
||||
<td>
|
||||
|
|
18
spec/controllers/about_controller_spec.rb
Normal file
18
spec/controllers/about_controller_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AboutController, type: :controller do
|
||||
it "renders the staff template" do
|
||||
get :staff
|
||||
expect(response).to render_template("staff")
|
||||
end
|
||||
|
||||
it "renders the adminpanel template" do
|
||||
get :adminpanel
|
||||
expect(response).to render_template("adminpanel")
|
||||
end
|
||||
|
||||
it "renders the statistics template" do
|
||||
get :statistics
|
||||
expect(response).to render_template("statistics")
|
||||
end
|
||||
end
|
|
@ -20,7 +20,7 @@ require 'rspec/rails'
|
|||
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
||||
# require only the support files necessary.
|
||||
#
|
||||
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
|
||||
# Checks for pending migrations before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
|
|
14
spec/support/spec_login_helper.rb
Normal file
14
spec/support/spec_login_helper.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
module SpecLoginHelper
|
||||
def login_admin
|
||||
login(:admin)
|
||||
end
|
||||
|
||||
def login(user)
|
||||
user = User.where(:login => user.to_s).first if user.is_a?(Symbol)
|
||||
request.session[:user] = user.id
|
||||
end
|
||||
|
||||
def current_user
|
||||
User.find(request.session[:user])
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue