Skip to content

Commit

Permalink
Fix bare statement partial matching
Browse files Browse the repository at this point in the history
Statements without qualifiers should be partial matches so they are
updated instead of creating brand new statements.
  • Loading branch information
gbp committed Oct 25, 2018
1 parent e884fec commit f367ee5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/membership_comparison/term_comparison.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _conflict?

def _partial?
!suggestion_started_after_statement_ended? && (
no_term_or_statement_start? ||
term_started_during_statement? ||
(statement_open? && term_open? && term_started_after_statement?)
)
Expand All @@ -40,5 +41,9 @@ def previous_term_still_open?
!suggestion_started_after_statement_ended? &&
suggestion_started_after_statement_and_term?
end

def no_term_or_statement_start?
!statement_value && !statement_started?
end
end
end
4 changes: 2 additions & 2 deletions spec/membership_comparison_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
specify { expect(comparison.problems).to be_empty }
end

xcontext 'existing base P39s' do
context 'existing base P39s' do
let(:comparison) do
MembershipComparison.new(
existing: {
Expand All @@ -52,7 +52,7 @@
end

specify { expect(comparison.exact_matches).to be_empty }
specify { expect(comparison.partial_matches).to match_array(['wds:1030-1DAA-3101', 'wds:1030-1DAA-3102']) } # Currently fails
specify { expect(comparison.partial_matches).to match_array(['wds:1030-1DAA-3101', 'wds:1030-1DAA-3102']) }
specify { expect(comparison.conflicts).to be_empty }
specify { expect(comparison.problems['wds:1030-1DAA-3101']).to be_empty }
specify { expect(comparison.problems['wds:1030-1DAA-3102']).to be_empty }
Expand Down

0 comments on commit f367ee5

Please sign in to comment.