diff --git a/Gemfile b/Gemfile index 97f534b..aab5f18 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'dotenv-rails' gem 'sass-rails', '~> 5.0' gem 'sassc-rails' gem 'bourbon' -gem 'normalize-rails', github: 'markmcconachie/normalize-rails' +gem 'normalize-rails' # Javascript gem 'uglifier', '>= 1.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 0f8608d..feba656 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,234 +1,236 @@ -GIT - remote: git://github.com/markmcconachie/normalize-rails.git - revision: 671ca8fd780bcc5f4ed67c9d3c65cd8d63935fa0 - specs: - normalize-rails (3.0.3) - GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.2) - actionpack (= 4.2.2) - actionview (= 4.2.2) - activejob (= 4.2.2) + actionmailer (4.2.5.1) + actionpack (= 4.2.5.1) + actionview (= 4.2.5.1) + activejob (= 4.2.5.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.2) - actionview (= 4.2.2) - activesupport (= 4.2.2) + actionpack (4.2.5.1) + actionview (= 4.2.5.1) + activesupport (= 4.2.5.1) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - actionview (4.2.2) - activesupport (= 4.2.2) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - activejob (4.2.2) - activesupport (= 4.2.2) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (4.2.5.1) + activesupport (= 4.2.5.1) globalid (>= 0.3.0) - activemodel (4.2.2) - activesupport (= 4.2.2) + activemodel (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) - activerecord (4.2.2) - activemodel (= 4.2.2) - activesupport (= 4.2.2) + activerecord (4.2.5.1) + activemodel (= 4.2.5.1) + activesupport (= 4.2.5.1) arel (~> 6.0) - activesupport (4.2.2) + activesupport (4.2.5.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (6.0.0) - bourbon (4.2.3) + addressable (2.4.0) + arel (6.0.3) + bourbon (4.2.6) sass (~> 3.4) - thor - bugsnag (2.8.7) - multi_json (~> 1.0) + thor (~> 0.19) + bugsnag (3.0.0) + json (~> 1.7, >= 1.7.7) builder (3.2.2) - capybara (2.4.4) + capybara (2.6.2) + addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) cliver (0.3.2) - codeclimate-test-reporter (0.4.7) + codeclimate-test-reporter (0.4.8) simplecov (>= 0.7.1, < 1.0.0) - coderay (1.1.0) - coffee-rails (4.1.0) + coderay (1.1.1) + coffee-rails (4.1.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) + railties (>= 4.0.0, < 5.1.x) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.9.1.1) - database_cleaner (1.4.1) + coffee-script-source (1.10.0) + concurrent-ruby (1.0.0) + database_cleaner (1.5.1) diff-lcs (1.2.5) docile (1.1.5) - dotenv (2.0.1) - dotenv-rails (2.0.1) - dotenv (= 2.0.1) + dotenv (2.1.0) + dotenv-rails (2.1.0) + dotenv (= 2.1.0) + railties (>= 4.0, < 5.1) elo2 (0.1.0) erubis (2.7.0) - execjs (2.5.2) + execjs (2.6.0) factory_girl (4.5.0) activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) + factory_girl_rails (4.6.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) - faraday (0.9.1) + faraday (0.9.2) multipart-post (>= 1.2, < 3) fast_stack (0.1.0) rake rake-compiler - ffi (1.9.8) + ffi (1.9.10) flamegraph (0.1.0) fast_stack - globalid (0.3.5) + globalid (0.3.6) activesupport (>= 4.1.0) - hamlit (2.2.0) + hamlit (2.2.2) temple (~> 0.7.6) thor tilt i18n (0.7.0) - jbuilder (2.2.16) - activesupport (>= 3.0.0, < 5) + jbuilder (2.4.1) + activesupport (>= 3.0.0, < 5.1) multi_json (~> 1.2) - jquery-rails (4.0.3) + jquery-rails (4.1.0) rails-dom-testing (~> 1.0) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.3) - loofah (2.0.2) + loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) method_source (0.8.2) - mime-types (2.6.1) - mini_portile (0.6.2) - minitest (5.7.0) - multi_json (1.11.0) + mime-types (2.6.2) + mini_portile2 (2.0.0) + minitest (5.8.4) + multi_json (1.11.2) multipart-post (2.0.0) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - pg (0.18.2) - poltergeist (1.6.0) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) + normalize-rails (3.0.3) + pg (0.18.4) + poltergeist (1.9.0) capybara (~> 2.1) cliver (~> 0.3.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) - pry (0.10.1) + pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-rails (0.3.4) pry (>= 0.9.10) - puma (2.11.3) - rack (>= 1.1, < 2.0) - rack (1.6.2) - rack-mini-profiler (0.9.3) + puma (2.16.0) + rack (1.6.4) + rack-mini-profiler (0.9.8) rack (>= 1.1.3) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.2) - actionmailer (= 4.2.2) - actionpack (= 4.2.2) - actionview (= 4.2.2) - activejob (= 4.2.2) - activemodel (= 4.2.2) - activerecord (= 4.2.2) - activesupport (= 4.2.2) + rails (4.2.5.1) + actionmailer (= 4.2.5.1) + actionpack (= 4.2.5.1) + actionview (= 4.2.5.1) + activejob (= 4.2.5.1) + activemodel (= 4.2.5.1) + activerecord (= 4.2.5.1) + activesupport (= 4.2.5.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.2) + railties (= 4.2.5.1) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.6) + rails-dom-testing (1.0.7) activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.2) - actionpack (= 4.2.2) - activesupport (= 4.2.2) + railties (4.2.5.1) + actionpack (= 4.2.5.1) + activesupport (= 4.2.5.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) + rake (10.5.0) rake-compiler (0.9.5) rake - rdoc (4.2.0) - rspec-core (3.2.3) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.1) + rdoc (4.2.2) + json (~> 1.4) + rspec-core (3.4.3) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-mocks (3.2.1) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-rails (3.2.2) + rspec-support (~> 3.4.0) + rspec-rails (3.4.2) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-support (~> 3.2.0) - rspec-support (3.2.2) - sass (3.4.14) - sass-rails (5.0.3) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) + sass (3.4.21) + sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) - tilt (~> 1.1) - sassc (1.2.0) + tilt (>= 1.1, < 3) + sassc (1.8.4) bundler ffi (~> 1.9.6) - sassc-rails (0.1.0) - rails (>= 4.0.0) + sass (>= 3.3.0) + sassc-rails (1.2.0) + railties (>= 4.0.0) sass - sassc (~> 1.2.0) + sassc (~> 1.6) sprockets (> 2.11) + sprockets-rails tilt sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - shoulda-matchers (2.8.0) - activesupport (>= 3.0.0) - simple_form (3.1.0) - actionpack (~> 4.0) - activemodel (~> 4.0) - simplecov (0.10.0) + shoulda-matchers (3.1.1) + activesupport (>= 4.0.0) + simple_form (3.2.1) + actionpack (> 4, < 5.1) + activemodel (> 4, < 5.1) + simplecov (0.11.2) docile (~> 1.1.0) json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - slack-notifier (1.2.1) + slack-notifier (1.5.1) slop (3.6.0) - sprockets (3.2.0) - rack (~> 1.0) - sprockets-rails (2.3.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - stackprof (0.2.7) + sprockets (3.5.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.0.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + stackprof (0.2.8) temple (0.7.6) thor (0.19.1) thread_safe (0.3.5) - tilt (1.4.1) + tilt (2.0.2) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.7.1) + uglifier (2.7.2) execjs (>= 0.3.0) json (>= 1.8.0) visdiff (0.0.7) faraday - websocket-driver (0.5.4) + websocket-driver (0.6.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) xpath (2.0.0) @@ -253,7 +255,7 @@ DEPENDENCIES jbuilder (~> 2.0) jquery-rails mime-types (~> 2.6.1) - normalize-rails! + normalize-rails pg poltergeist pry-rails diff --git a/app/assets/images/header-paddle.svg b/app/assets/images/header-paddle.svg new file mode 100644 index 0000000..cc951ff --- /dev/null +++ b/app/assets/images/header-paddle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index fe18b35..c123e60 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -7,3 +7,7 @@ //= require Chart //= require porkchop //= require phoenix + +// FIXME: Switch to using a pure webpack generated entrypoint once the match +// controls page is dead. +//= require entries/default diff --git a/app/assets/stylesheets/_base.scss b/app/assets/stylesheets/_base.scss index d1a993d..069e624 100644 --- a/app/assets/stylesheets/_base.scss +++ b/app/assets/stylesheets/_base.scss @@ -2,7 +2,6 @@ body { margin: 0; - background-color: $dark-grey; } select { @@ -12,13 +11,13 @@ select { a { &:link, &:visited { - color: $green; + color: $blue; text-decoration: none; } &:hover, &:active { - color: darken($green, 10); + color: lighten($blue, 10); text-decoration: underline; } } diff --git a/app/assets/stylesheets/_flashes.scss b/app/assets/stylesheets/_flashes.scss new file mode 100644 index 0000000..4ab8c3b --- /dev/null +++ b/app/assets/stylesheets/_flashes.scss @@ -0,0 +1,21 @@ +.site-flash-wrap { + color: white; + box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1); + position: relative; + z-index: 1; + + &.notice { + background-color: lighten($blue, 15); + } + + &.error { + background-color: lighten($red, 5); + } +} + +.site-flash { + @include margin(0 auto); + @include padding(0.5rem 0); + max-width: 500px; + text-align: center; +} diff --git a/app/assets/stylesheets/_header-controls.scss b/app/assets/stylesheets/_header-controls.scss new file mode 100644 index 0000000..863d7fd --- /dev/null +++ b/app/assets/stylesheets/_header-controls.scss @@ -0,0 +1,87 @@ +.header-controls-wrap { + display: none; + @include padding(1rem); + background-color: $green; + box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1); + position: relative; + z-index: 2; + + .controls-open & { + display: block; + } + + .requires-write-access { + display: none; + + .has-write-access & { + display: block; + } + } + + .has-write-access & .hide-for-write-access { + display: none; + } +} + +.header-controls { + @include margin(0 auto); + max-width: 900px; + color: white; +} + +.site-navigation { + @include padding(0); + @include margin(0); + list-style-type: none; + + li { + font-size: 14px; + @include padding(0.25rem 0); + } + + a { + display: block; + color: white; + font-weight: $font-weight-bold; + } +} + +.authentication-form { + @include margin(1rem auto 0 auto); + max-width: 256px; + background-color: darken($green, 5%); + @include padding(0.5rem); + text-align: center; + + label { + color: white; + font-size: 12px; + text-transform: uppercase; + font-weight: $font-weight-bold; + letter-spacing: 0.1em; + display: block; + } + + input[type=password] { + @include padding(0.25rem); + @include margin(0.5rem 0); + color: white; + background-color: transparent; + border: 2px solid white; + height: 2rem; + line-height: 1.5rem; + outline: none; + } + + input[type=submit] { + @include margin(0.125rem 0); + @include padding(0.25rem 0.5rem); + background-color: $blue; + color: white; + font-size: 12px; + text-transform: uppercase; + font-weight: $font-weight-bold; + letter-spacing: 0.1em; + border: none; + } +} diff --git a/app/assets/stylesheets/_header.scss b/app/assets/stylesheets/_header.scss index b7f6364..4f77cdf 100644 --- a/app/assets/stylesheets/_header.scss +++ b/app/assets/stylesheets/_header.scss @@ -1,93 +1,81 @@ -.main-header { - line-height: 2.5; - font-size: modular-scale(1); - background-color: $off-white; - - a { - color: inherit; - text-decoration: none; - - &:hover, - &:active { - text-decoration: underline; - } - } +$header-height: 48px; +$header-padding: 20px; + +.main-header-wrap { + @include padding(0 1rem); + @include linear-gradient(90deg, $color-porkchop-red 0%, $color-porkchop-red 50%, $color-porkchop-blue 51%, $color-porkchop-blue 100%); + box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1); + position: relative; + z-index: 3; } -.main-title { - padding: 0.5em 0.5rem; - margin-top: 0; - margin-bottom: 0; - font-size: inherit; - line-height: 1.3; - - a { - &:link, - &:visited { - display: inline-block; - border-radius: 2px; - text-decoration: none; - } - - &:hover, - &:active { - } - } - - span { - color: $dark-grey; - - &:first-child { - font-weight: $font-weight-light; - } - - &:last-child { - font-weight: $font-weight-bold; +.main-header { + @include clearfix; + @include margin(0 auto); + max-width: 1024px - 2 * $header-padding; + background-color: $color-porkchop-blue; + + .site-title { + float: left; + line-height: $header-height; + font-size: 24px; + background-color: $color-porkchop-red; + + a { + font-weight: bold; + color: #fff; + + span { + font-size: 16px; + font-weight: 400; + // Hack so it doesn't affect the height of the .site-title element. + line-height: 0; + } } } } -.primary-navigation, -.secondary-navigation { - font-size: modular-scale(-1); - line-height: 1.6; - - @include phone { - text-align: center; - } +.main-header-paddle { + float: left; + height: $header-height; +} - ul { - list-style-type: none; - margin: 0; - padding: 0 0.5rem; +.main-header-menu-button { + $button-width: 28px; + $button-height: 24px; + $bar-height: 4px; + float: right; + @include size($button-width $button-height); + @include margin((($header-height - $button-height) / 2) 0); + $border: $bar-height solid white; + border-top: $border; + border-bottom: $border; + position: relative; + cursor: pointer; + @include transition(125ms); + + &:before, + &:after { + content: ''; + display: block; + height: $bar-height; + background-color: white; + top: ($button-height - 3 * $bar-height) / 2; + right: 0; + left: 0; + position: absolute; + @include transition(125ms); } - li { - display: inline; + &.active { + border-color: transparent; - margin-right: 0.75em; - - &:last-child { - margin-right: 0; + &:before { + @include transform(rotate(-45deg)); } - } -} -.primary-navigation { - background-color: $dark-grey; - @include padding(0.25em null); - - a { - color: $off-white; - text-transform: uppercase; - } -} - -.secondary-navigation { - background-color: darken($off-white, 3); - text-align: right; - - a { - color: $dark-grey; + &:after { + @include transform(rotate(45deg)); + } } } diff --git a/app/assets/stylesheets/_palette.scss b/app/assets/stylesheets/_palette.scss index c948b14..8b87871 100644 --- a/app/assets/stylesheets/_palette.scss +++ b/app/assets/stylesheets/_palette.scss @@ -1,7 +1,10 @@ $off-white: #FEFEFE; $dark-grey: #29262D; -$red: #B63D23; -$blue: #206393; -$green: #286F4C; +$color-porkchop-blue: #24306F; +$color-porkchop-red: #CD3117; + +$red: $color-porkchop-red; +$blue: $color-porkchop-blue; +$green: #286F31; $yellow: #E8CC3B; diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index ea5be36..6bf2092 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -14,6 +14,8 @@ @import "layout"; @import "header"; @import "footer"; +@import "header-controls"; +@import "flashes"; @import "homepage"; diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 9176c6b..18f9ab5 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -2,9 +2,9 @@ class SessionsController < ApplicationController def authenticate if params[:password] == ENV['WRITE_ACCESS_PASSWORD'] session[:write_access] = true - render nothing: true, status: :ok + redirect_to :back, flash: { notice: "Access granted." } else - render nothing: true, status: :unauthorized + redirect_to :back, flash: { error: "Access denied." } end end end diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 05fec84..8447016 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,16 +1,26 @@ -%header.main-header - %nav.secondary-navigation - - unless write_access? +%nav.main-navigation{ class: [write_access? && "has-write-access"] } + .main-header-wrap + %header.main-header + %h1.site-title + = link_to root_path do + PorkChop.Club + = image_tag "header-paddle.svg", class: "main-header-paddle" + .main-header-menu-button + .header-controls-wrap + .header-controls + %ul.site-navigation + %li.requires-write-access= link_to "Match Controls", edit_scoreboard_path + %li= link_to "Players", players_path + %li= link_to "Match History", matches_path + + .authentication-form.hide-for-write-access = form_tag login_path do - = label_tag "Authenticate:" - = text_field_tag :password + = label_tag "Authenticate" + = password_field_tag :password + %br = submit_tag "Submit" - %h1.main-title - = link_to root_path do - %span PorkChop  - %span Club League - %nav.primary-navigation - %ul - %li= link_to "Match Controls", edit_scoreboard_path - %li= link_to "Players", players_path - %li= link_to "Match History", matches_path + + - flash.each do |name, message| + .site-flash-wrap{ class: name } + .site-flash= message + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 52efc0a..3945e0e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,9 +2,9 @@ %html = render "layouts/head" %body - .outer-container - = render "layouts/header" + = render "layouts/header" + .outer-container = yield = render "layouts/footer" diff --git a/app/webpack/components/header.js b/app/webpack/components/header.js new file mode 100644 index 0000000..99ca5ee --- /dev/null +++ b/app/webpack/components/header.js @@ -0,0 +1,13 @@ +import $ from 'jquery'; + +module.exports = ($element) => { + let isMenuOpen = + $element + .asEventStream('click', '.main-header-menu-button') + .scan(false, (value) => !value); + + isMenuOpen + .assign($('.main-header-menu-button'), 'toggleClass', 'active'); + isMenuOpen + .assign($element, 'toggleClass', 'controls-open'); +}; diff --git a/app/webpack/default.js b/app/webpack/default.js new file mode 100644 index 0000000..20ae48e --- /dev/null +++ b/app/webpack/default.js @@ -0,0 +1,5 @@ +import './shared'; +import header from './components/header'; + +$(() => header($('.main-navigation'))); + diff --git a/app/webpack/scoreboard.js b/app/webpack/scoreboard.js index d6c6fa4..dd11cf3 100644 --- a/app/webpack/scoreboard.js +++ b/app/webpack/scoreboard.js @@ -1,7 +1,6 @@ -import $ from 'jquery'; +import './shared'; -// FIXME: Pull this out into shared setup. -import './baconExtensions'; +import $ from 'jquery'; import ongoingMatch from './observables/ongoingMatch'; diff --git a/app/webpack/shared.js b/app/webpack/shared.js new file mode 100644 index 0000000..abaa0ab --- /dev/null +++ b/app/webpack/shared.js @@ -0,0 +1 @@ +import './baconExtensions'; diff --git a/spec/controllers/api/table_controller_spec.rb b/spec/controllers/api/table_controller_spec.rb index 19b7ced..b9dbe65 100644 --- a/spec/controllers/api/table_controller_spec.rb +++ b/spec/controllers/api/table_controller_spec.rb @@ -74,7 +74,6 @@ before do expect(PingPong::Rewind). to receive(:new). - with(match). and_return(rewind) expect(rewind). diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 7b7d907..23f4655 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -11,21 +11,21 @@ context "with the wrong password" do let(:password) { "psswrd" } - it { is_expected.to have_http_status :unauthorized } - - it "sets the authenticates the session" do + it "doesn't authenticate the session" do expect { subject }.not_to change { session[:write_access] } end + + it { is_expected.to redirect_to "/the/future" } end context "with the correct password" do let(:password) { "password" } - it { is_expected.to have_http_status :ok } - - it "sets the authenticates the session" do + it "authenticates the session" do expect { subject }.to change { session[:write_access] }.from(nil).to(true) end + + it { is_expected.to redirect_to "/the/future" } end end end diff --git a/spec/features/controls_spec.rb b/spec/features/controls_spec.rb index 0809a87..3a7c9cb 100644 --- a/spec/features/controls_spec.rb +++ b/spec/features/controls_spec.rb @@ -11,6 +11,8 @@ scenario "recording a normal game" do visit "/" + expect(page).to have_css '.main-header-menu-button' + find('.main-header-menu-button').click fill_in :password, with: "password" click_button "Submit" visit "/scoreboard/edit" diff --git a/spec/models/ping_pong/match_spec.rb b/spec/models/ping_pong/match_spec.rb index 01a55b3..0b250f5 100644 --- a/spec/models/ping_pong/match_spec.rb +++ b/spec/models/ping_pong/match_spec.rb @@ -313,7 +313,7 @@ before do expect(PingPong::Commentator). to receive(:new). - with(match: match) { commentator } + and_return(commentator) expect(commentator).to receive(:comment) { 'foo' } end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 42002ac..d68613e 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -12,6 +12,13 @@ ActiveRecord::Migration.maintain_test_schema! +Shoulda::Matchers.configure do |config| + config.integrate do |with| + with.test_framework :rspec + with.library :rails + end +end + RSpec.configure do |config| config.use_transactional_fixtures = false diff --git a/spec/visual/visual_spec.rb b/spec/visual/visual_spec.rb index 372ab2a..4b5a19f 100644 --- a/spec/visual/visual_spec.rb +++ b/spec/visual/visual_spec.rb @@ -28,6 +28,8 @@ before do visit '/' + expect(page).to have_css '.main-header-menu-button' + find('.main-header-menu-button').click fill_in :password, with: "password" click_button "Submit" end diff --git a/webpack.config.js b/webpack.config.js index 87c22c2..5bc65ff 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,6 +8,7 @@ config.context = __dirname; config.entry = { scoreboard: './app/webpack/scoreboard.js', + default: './app/webpack/default.js' }; config.output = {