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

pulibrary / pdc_describe / 4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

07 Apr 2025 06:36PM UTC coverage: 1.283% (-94.6%) from 95.862%
4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

Pull #1994

circleci

hectorcorrea
Switched to use the autocomplete that we aleady use for ROR. Integrated it with the existing logic for creators
Pull Request #1994: Started adding auto complete to contributors

0 of 46 new or added lines in 2 files covered. (0.0%)

4806 existing lines in 74 files now uncovered.

65 of 5065 relevant lines covered (1.28%)

0.01 hits per line

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

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

UNCOV
3
class WorkCompareService
×
UNCOV
4
  attr_reader :differences
×
5

UNCOV
6
  class << self
×
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
UNCOV
12
    def update_work(work:, update_params:, current_user:)
×
UNCOV
13
      work_before = work.dup
×
UNCOV
14
      if work.update(update_params)
×
UNCOV
15
        work_compare = new(work_before, work)
×
UNCOV
16
        work.log_changes(work_compare, current_user.id)
×
UNCOV
17
        true
×
UNCOV
18
      else
×
UNCOV
19
        false
×
UNCOV
20
      end
×
UNCOV
21
    end
×
UNCOV
22
  end
×
23

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

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

UNCOV
35
  private
×
36

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

UNCOV
41
    def compare_works
×
42
      # Compare the group
UNCOV
43
      if @before.group != @after.group
×
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 }]
×
UNCOV
47
      end
×
48

UNCOV
49
      @differences = @differences.merge(resource_compare_service.differences)
×
UNCOV
50
    end
×
UNCOV
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