Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
JensRavens committed Jan 6, 2025
1 parent 0382b6c commit ed623e6
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/models/leave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ def notify_slack_about_sick_leave
end

def notify_hr_on_slack_about_new_request
Slack.instance.notify(channel: Config.slack_hr_channel_id,
text: Leave::Notification.new(leave: self).hr_leave_request_message) if Config.slack_hr_channel_id.present?
if Config.slack_hr_channel_id.present?
Slack.instance.notify(channel: Config.slack_hr_channel_id,
text: Leave::Notification.new(leave: self).hr_leave_request_message)
end
end

def notify_user_on_slack_about_status_change
Expand Down
2 changes: 2 additions & 0 deletions app/views/components/_current_user.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

field :current_user, global: :current_user do
field :id
field :display_name
Expand Down
2 changes: 2 additions & 0 deletions app/views/inventories/edit.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

field :inventory, value: -> { @inventory } do
field :id
field :name
Expand Down
2 changes: 2 additions & 0 deletions app/views/inventories/new.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

field :user, value: -> { @inventory.user } do
field :id
end
2 changes: 2 additions & 0 deletions app/views/leaves/index.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :feed_url, value: -> { helpers.feed_leaves_url(auth: current_user.id, format: :ics, protocol: :webcal) }
Expand Down
2 changes: 2 additions & 0 deletions app/views/leaves/new.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :permit_user_select, Boolean, value: -> { helpers.policy(Leave).show_all_users? }
Expand Down
2 changes: 2 additions & 0 deletions app/views/pages/home.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :upcoming_leaves, array: true, value: -> { @upcoming_leaves } do
Expand Down
2 changes: 2 additions & 0 deletions app/views/payslips/index.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :payslips, array: true, value: -> { @payslips } do
Expand Down
2 changes: 2 additions & 0 deletions app/views/payslips/new.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

field :users, array: true, value: -> { User.currently_employed.alphabetically } do
field :id
field :display_name
Expand Down
2 changes: 2 additions & 0 deletions app/views/sprint_feedbacks/show.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :feedback, value: -> { @feedback } do
Expand Down
2 changes: 2 additions & 0 deletions app/views/sprints/index.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :sprints, array: true, value: -> { @sprints } do
Expand Down
2 changes: 2 additions & 0 deletions app/views/users/index.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :filter, value: -> { @filter }
Expand Down
2 changes: 2 additions & 0 deletions app/views/users/show.props.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

render "components/current_user"

field :user, value: -> { @user } do
Expand Down
2 changes: 2 additions & 0 deletions lib/reaction.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module Reaction
end
4 changes: 3 additions & 1 deletion lib/reaction/controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Reaction
module Controller
extend ActiveSupport::Concern
Expand All @@ -16,7 +18,7 @@ def default_render
end
format.json do
return head :no_content if reaction_request?
render json: Response.new(component: "#{controller_path}/#{action_name}", context: self.view_context).to_s
render json: Response.new(component: "#{controller_path}/#{action_name}", context: view_context).to_s
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/reaction/props/field.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Reaction
module Props
class Field
Expand Down
4 changes: 3 additions & 1 deletion lib/reaction/props/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Reaction
module Props
class Schema
Expand All @@ -6,7 +8,7 @@ class Schema

def initialize(string)
@root = Field.new(:root, Object, null: false, parent: self)
@root.instance_exec { binding.eval(string) }
@root.instance_exec { binding.eval(string) } # rubocop:disable Security/Eval the imported string is under the developers control and therefore should not include any injections
end

def serialize(object)
Expand Down
2 changes: 2 additions & 0 deletions lib/reaction/props/value_proxy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Reaction
module Props
class ValueProxy < SimpleDelegator
Expand Down
2 changes: 2 additions & 0 deletions lib/reaction/response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Reaction
class Response
attr_reader :schema, :component
Expand Down
2 changes: 2 additions & 0 deletions lib/reaction/tsx_handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Reaction
class TsxHandler
class << self
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/files/example_schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

field :current_user do
field :first_name
field :email, null: false
Expand Down
6 changes: 3 additions & 3 deletions spec/models/prop_schema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require "rails_helper"

RSpec.describe PropSchema do
RSpec.describe Reaction::Props::Schema do
describe "#initialize" do
it "parses a tree of properties using a DSL" do
schema = PropSchema.new(Rails.root.join("spec/fixtures/files/example_schema.rb"))
schema = Reaction::Props::Schema.new(Rails.root.join("spec/fixtures/files/example_schema.rb"))
root = schema.root
current_user = root.fields[:current_user]
expect(root.name).to eq :root
Expand All @@ -20,7 +20,7 @@

describe "#serialize" do
it "serializes a tree of properties" do
schema = PropSchema.new(Rails.root.join("spec/fixtures/files/example_schema.rb"))
schema = Reaction::Props::Schema.new(Rails.root.join("spec/fixtures/files/example_schema.rb"))
serialized = schema.serialize(OpenStruct.new({
current_user: {
first_name: "John",
Expand Down

0 comments on commit ed623e6

Please sign in to comment.