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

pulibrary / pdc_describe / b1776731-62d7-41a7-882d-6a5b4760db75

14 May 2024 12:28PM UTC coverage: 79.223% (-16.7%) from 95.9%
b1776731-62d7-41a7-882d-6a5b4760db75

push

circleci

carolyncole
Adding a submission completion page

fixes #1791

9 of 9 new or added lines in 2 files covered. (100.0%)

567 existing lines in 42 files now uncovered.

2692 of 3398 relevant lines covered (79.22%)

60.03 hits per line

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

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

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

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

35
  private
1✔
36

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

41
    def compare_works
1✔
42
      # Compare the group
43
      if @before.group != @after.group
39✔
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)
39✔
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