This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +8
-26
lines changed Expand file tree Collapse file tree 4 files changed +8
-26
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,6 @@ def initialize(payload)
59
59
@improved_constants_payload = data . merge ( "constants" => improved_constants ) if improved_constants . any?
60
60
end
61
61
62
- def changed?
63
- alert_constants_payload . present? || improved_constants_payload . present?
64
- end
65
-
66
62
private
67
63
68
64
def new_constants_selector
Original file line number Diff line number Diff line change @@ -23,13 +23,7 @@ def receive_test
23
23
end
24
24
25
25
def receive_snapshot
26
- snapshot = CC ::Formatters ::SnapshotFormatter ::Base . new ( payload )
27
-
28
- if snapshot . changed?
29
- send_snapshot_to_slack ( snapshot )
30
- else
31
- { ok : false , ignored : true , message : "No changes in snapshot" }
32
- end
26
+ send_snapshot_to_slack ( CC ::Formatters ::SnapshotFormatter ::Base . new ( payload ) )
33
27
end
34
28
35
29
def receive_coverage
@@ -71,12 +65,14 @@ def speak(message, color = nil)
71
65
72
66
def send_snapshot_to_slack ( snapshot )
73
67
if snapshot . alert_constants_payload
74
- speak ( alerts_message ( snapshot . alert_constants_payload ) , RED_HEX )
68
+ @response = speak ( alerts_message ( snapshot . alert_constants_payload ) , RED_HEX )
75
69
end
76
70
77
71
if snapshot . improved_constants_payload
78
- speak ( improvements_message ( snapshot . improved_constants_payload ) , GREEN_HEX )
72
+ @response = speak ( improvements_message ( snapshot . improved_constants_payload ) , GREEN_HEX )
79
73
end
74
+
75
+ @response || { ok : false , ignored : true , message : "No changes in snapshot" }
80
76
end
81
77
82
78
def alerts_message ( constants_payload )
Original file line number Diff line number Diff line change @@ -44,16 +44,4 @@ def test_snapshot_formatter_test_with_relaxed_constraints
44
44
refute_nil f . alert_constants_payload
45
45
refute_nil f . improved_constants_payload
46
46
end
47
-
48
- def test_changed_when_snapshot_changed
49
- f = described_class . new ( { "new_constants" => [ ] ,
50
- "changed_constants" => [ { "to" => { "rating" => "A" } , "from" => { "rating" => "D" } } ]
51
- } )
52
- assert f . changed?
53
- end
54
-
55
- def test_changed_when_no_changes
56
- f = described_class . new ( { "new_constants" => [ ] , "changed_constants" => [ ] } )
57
- refute f . changed?
58
- end
59
47
end
Original file line number Diff line number Diff line change @@ -80,11 +80,13 @@ def test_quality_alert_with_new_constants
80
80
"changed_constants" => [ ] ,
81
81
"compare_url" => "https://codeclimate.com/repos/1/compare/a...z" }
82
82
83
- assert_slack_receives ( CC ::Service ::Slack ::RED_HEX , data ,
83
+ response = assert_slack_receives ( CC ::Service ::Slack ::RED_HEX , data ,
84
84
"" "Quality alert triggered for *Rails* (<https://codeclimate.com/repos/1/compare/a...z|Compare>)
85
85
86
86
• _Foo_ was just created and is a *D*
87
87
• _bar.js_ was just created and is an *F*" "" )
88
+
89
+ assert response [ :ok ]
88
90
end
89
91
90
92
def test_quality_alert_with_new_constants_and_declined_constants
You can’t perform that action at this time.
0 commit comments