Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo: commit untested code #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Rails Unit Tests
on: [push, pull_request]
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -20,6 +20,6 @@ jobs:
bundle exec rails db:migrate
bundle exec rails test
ruby -e "$(curl -s https://undercover-ci.com/uploader.rb)" -- \
--repo twitchy-tortoise/undercover-test \
--commit $GITHUB_SHA \
--lcov coverage/lcov/undercover-test.lcov
--repo twitchy-tortoise/undercover-test \
--commit ${{ github.event.pull_request.head.sha || github.sha }} \
--lcov coverage/lcov/undercover-test.lcov
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class ApplicationController < ActionController::Base
def check_cookie
if params[:x] != ENV.fetch("CODE", "beta")
redirect_to(bounce_home_index_url) and return
end

cookies[:beta_sign_in] = { value: 1, expires: 1.year }
end

Check warning on line 8 in app/controllers/application_controller.rb

View check run for this annotation

UndercoverCI / coverage

Untested instance method

Instance method `check_cookie` is missing coverage for lines 3..4,7 (node coverage: 0.0). Missing branch coverage found in line 3.
Raw output
2:   def check_cookie hits: n/a
3:     if params[:x] != ENV.fetch("CODE", "beta") hits: 0 branches: 0/2
4:       redirect_to(bounce_home_index_url) and return hits: 0
5:     end hits: n/a
6: 
7:     cookies[:beta_sign_in] = { value: 1, expires: 1.year } hits: 0
8:   end hits: n/a

private

def check_beta_cookie
Expand Down
1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class HomeController < ApplicationController
before_action :check_beta_cookie, only: :index

def index
@say = self.class.name
end

def bounce
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Hi! ✅
From: <%= controller.class.name %>
From: <%= @say %>
Loading