Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
oma-s committed Apr 22, 2024
1 parent 853bfd5 commit b58323b
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/controllers/sprints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def new
def create
@sprint = authorize Sprint.new(sprint_attributes)
User.sprinter.each do |user|
@sprint.sprint_feedbacks.build user: user
@sprint.sprint_feedbacks.build user:
end
if @sprint.save
ui.navigate_to sprints_path
Expand Down
4 changes: 1 addition & 3 deletions app/jobs/slack_set_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ class SlackSetStatusJob < ApplicationJob
sidekiq_options retry: 0

def perform
Leave.approved.starts_today.each do |leave|
leave.set_slack_status!
end
Leave.approved.starts_today.each(&:set_slack_status!)
end
end
2 changes: 1 addition & 1 deletion app/models/leave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def notify_user_on_slack_about_status_change

def set_slack_status!
emoji = Leave::Presenter.new(self).slack_emoji
user.slack_profile.set_status(type: type, emoji:, until_date: leave_during.max)
user.slack_profile.set_status(type:, emoji:, until_date: leave_during.max)
end

delegate :to_ics, to: :presenter
Expand Down
2 changes: 1 addition & 1 deletion app/models/time_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def assign_task
number = notes.scan(/#(\d+)/).flatten.first
return if number.nil?

task = Task.find_by(project_id: project_id, issue_number: number)
task = Task.find_by(project_id:, issue_number: number)
return if task.nil?

update! task_id: task.id
Expand Down
6 changes: 3 additions & 3 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
APP_PATH = File.expand_path("../config/application", __dir__).freeze
require_relative "../config/boot"
require "rails/commands"
4 changes: 2 additions & 2 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative '../config/boot'
require 'rake'
require_relative "../config/boot"
require "rake"
Rake.application.run
14 changes: 7 additions & 7 deletions bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
Expand All @@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
end
end

require 'rubygems'
require 'bundler/setup'
require "rubygems"
require "bundler/setup"

load Gem.bin_path('rspec-core', 'rspec')
load Gem.bin_path("rspec-core", "rspec")
18 changes: 9 additions & 9 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'fileutils'
require "fileutils"

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
APP_ROOT = File.expand_path("..", __dir__).freeze

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -15,9 +15,9 @@ FileUtils.chdir APP_ROOT do
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

puts "\n== Installing node modules =="
system! "yarn install"
Expand All @@ -28,13 +28,13 @@ FileUtils.chdir APP_ROOT do
# end

puts "\n== Preparing database =="
system! 'bin/rails db:prepare'
system! "bin/rails db:prepare"

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"

if system('overmind status')
if system("overmind status")
puts "\n== Restarting running processes =="
system! 'overmind restart'
system! "overmind restart"
end
end
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += %w[application.js]
Rails.application.config.assets.precompile += ["application.js"]
1 change: 1 addition & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
Expand Down
1 change: 1 addition & 0 deletions config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

sprints.each do |sprint|
user.sprint_feedbacks.create!(
sprint: sprint,
sprint:,
daily_nerd_count: Faker::Number.between(from: 0, to: sprint.working_days),
tracked_hours: Faker::Number.between(from: 20, to: sprint.working_days * 8.0),
billable_hours: Faker::Number.between(from: 10, to: sprint.working_days * 6.0),
Expand Down
2 changes: 2 additions & 0 deletions spec/models/leave_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
allow(leave).to receive(:notify_hr_on_slack_about_new_request)
end
end

it "notifies slack about sick leave for sick type" do
single_day_sick_leave.handle_incoming_request

Expand Down Expand Up @@ -149,6 +150,7 @@
allow(leave).to receive(:set_slack_status!)
end
end

it "sets slack status if leave is during today and approved" do
holiday.approved!
travel_to holiday.leave_during.min
Expand Down
2 changes: 1 addition & 1 deletion spec/models/slack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
stub_request(:get, "https://slack.com/api/users.lookupByEmail?email=someone@nerdgeschoss.de")
.to_return(status: 200, body: {error: "not_found"}.to_json, headers: {"Content-Type": "application/json"})
expect(slack.retrieve_users_slack_id_by_email("jon@nerdgeschoss.de")).to eq "15"
expect(slack.retrieve_users_slack_id_by_email("someone@nerdgeschoss.de")).to eq nil
expect(slack.retrieve_users_slack_id_by_email("someone@nerdgeschoss.de")).to be_nil
end

it "sends a message to a channel" do
Expand Down
1 change: 1 addition & 0 deletions spec/models/sprint_feedback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
feedback.user.leaves.create! type: :paid, title: "Holidays", days: ["2023-01-26"], status: :rejected
feedback.user.leaves.create! type: :sick, title: "Sick", days: ["2023-01-27"]
end

it "takes all non rejected leave types into account" do
expect(feedback.working_day_count).to eq feedback.sprint.working_days - 4
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@

Task.sync_with_github

expect(Task.exists?(task.id)).to eq false
expect(Task.exists?(task.id)).to be false
end

it "does not delete tasks that are not in the list if they are done" do
task = tasks :done

Task.sync_with_github

expect(Task.exists?(task.id)).to eq true
expect(Task.exists?(task.id)).to be true
end

it "only updates finished_storypoints" do
Expand Down
1 change: 1 addition & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

context "notified about a message" do
let(:john) { users(:john_no_slack) }

it "updates the slack id on first use" do
expect(john).to have_attributes email: "john-no-slack@example.com", slack_id: nil
allow(Slack.instance).to receive(:retrieve_users_slack_id_by_email).with("john-no-slack@example.com").and_return("slack-15")
Expand Down
4 changes: 4 additions & 0 deletions spec/presenters/leave_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
context "slack emoji" do
describe "for paid leave" do
let(:leave) { holiday }

it "returns the palm tree emoji" do
expect(presenter.slack_emoji).to eq ":beach_with_umbrella:"
end
Expand All @@ -31,6 +32,7 @@

describe "for sick leave" do
let(:leave) { single_day_sick_leave }

it "returns the sick emoji" do
expect(presenter.slack_emoji).to eq ":face_with_thermometer:"
end
Expand All @@ -52,6 +54,7 @@
context "unicode emoji" do
describe "for paid leave" do
let(:leave) { holiday }

it "returns the beach with umbrella emoji" do
expect(presenter.unicode_emoji).to eq "\u{1F3D6}"
end
Expand Down Expand Up @@ -83,6 +86,7 @@

describe "for sick leave" do
let(:leave) { single_day_sick_leave }

it "returns the face with thermometer emoji" do
expect(presenter.unicode_emoji).to eq "\u{1F912}"
end
Expand Down

0 comments on commit b58323b

Please sign in to comment.