diff --git a/Dockerfile.dev b/Dockerfile.dev
index a852894..c216b6b 100644
--- a/Dockerfile.dev
+++ b/Dockerfile.dev
@@ -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
diff --git a/app/models/group.rb b/app/models/group.rb
index 734ea38..47f1f3b 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -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
diff --git a/app/models/grouper.rb b/app/models/grouper.rb
index 8d12162..65aee63 100644
--- a/app/models/grouper.rb
+++ b/app/models/grouper.rb
@@ -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
diff --git a/app/views/about/staff.html.erb b/app/views/about/staff.html.erb
index ae75282..48abe1a 100644
--- a/app/views/about/staff.html.erb
+++ b/app/views/about/staff.html.erb
@@ -37,7 +37,7 @@
<% Group.admins.each do |grouper| %>
- <%= flag grouper.user.country %> |
+ <%= flag grouper.user.country_s %> |
<%= namelink grouper.user %> |
<%= h grouper.user.email_s %> |
diff --git a/spec/controllers/about_controller_spec.rb b/spec/controllers/about_controller_spec.rb
new file mode 100644
index 0000000..42bb02e
--- /dev/null
+++ b/spec/controllers/about_controller_spec.rb
@@ -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
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 30599ee..cace4fe 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -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.
diff --git a/spec/support/spec_login_helper.rb b/spec/support/spec_login_helper.rb
new file mode 100644
index 0000000..3ca3a4e
--- /dev/null
+++ b/spec/support/spec_login_helper.rb
@@ -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
\ No newline at end of file
|