• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_describe / 9091a1ae-29be-458c-984a-339d213919c4

12 Dec 2024 07:41PM UTC coverage: 26.434% (-69.7%) from 96.113%
9091a1ae-29be-458c-984a-339d213919c4

Pull #2000

circleci

jrgriffiniii
Removing integration with ActiveStorage
Pull Request #2000: Bump actionpack from 7.2.1.1 to 7.2.2.1

945 of 3575 relevant lines covered (26.43%)

0.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.62
/app/services/work_compare_service.rb
1
# frozen_string_literal: true
2

3
class WorkCompareService
1✔
4
  attr_reader :differences
1✔
5

6
  class << self
1✔
7
    # Updates a work with the parameters and logs any changes
8
    # @param [Work] work work to be updated
9
    # @param [HashWithIndifferentAccess] update_params values to update the work with
10
    # @param [] current_user user currently logged into the system
11
    # @return [Boolean] true if update occured; false if update had errors
12
    def update_work(work:, update_params:, current_user:)
1✔
13
      work_before = work.dup
×
14
      if work.update(update_params)
×
15
        work_compare = new(work_before, work)
×
16
        work.log_changes(work_compare, current_user.id)
×
17
        true
×
18
      else
19
        false
×
20
      end
21
    end
22
  end
23

24
  def initialize(before, after)
1✔
25
    @before = before
×
26
    @after = after
×
27
    @differences = {}
×
28
    compare_works
×
29
  end
30

31
  def identical?
1✔
32
    @differences == {}
×
33
  end
34

35
  private
1✔
36

37
    def resource_compare_service
1✔
38
      @resource_compare_service ||= ResourceCompareService.new(@before.resource, @after.resource)
×
39
    end
40

41
    def compare_works
1✔
42
      # Compare the group
43
      if @before.group != @after.group
×
44
        before_value = @before.group
×
45
        after_value = @after.group
×
46
        @differences[:group] = [{ action: :changed, from: before_value.title, to: after_value.title }]
×
47
      end
48

49
      @differences = @differences.merge(resource_compare_service.differences)
×
50
    end
51
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc