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

pulibrary / pdc_describe / cace366a-ffad-45f1-9b60-678e607fa527

14 May 2024 02:21PM UTC coverage: 60.862% (-35.0%) from 95.908%
cace366a-ffad-45f1-9b60-678e607fa527

push

circleci

jrgriffiniii
wip

1 of 3 new or added lines in 2 files covered. (33.33%)

1194 existing lines in 57 files now uncovered.

2076 of 3411 relevant lines covered (60.86%)

22.71 hits per line

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

84.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
10✔
14
      if work.update(update_params)
10✔
15
        work_compare = new(work_before, work)
10✔
16
        work.log_changes(work_compare, current_user.id)
10✔
17
        true
10✔
18
      else
UNCOV
19
        false
×
20
      end
21
    end
22
  end
23

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

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

35
  private
1✔
36

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

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

49
      @differences = @differences.merge(resource_compare_service.differences)
10✔
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