Class: TestRunComparer
- Inherits:
-
Object
- Object
- TestRunComparer
- Defined in:
- app/interactors/test_run_comparer.rb
Instance Attribute Summary collapse
-
#test_run1 ⇒ Object
readonly
Returns the value of attribute test_run1.
-
#test_run2 ⇒ Object
readonly
Returns the value of attribute test_run2.
Class Method Summary collapse
Instance Method Summary collapse
- #compare! ⇒ Object
- #each_comparison(&block) ⇒ Object
-
#initialize(test_run1, test_run2) ⇒ TestRunComparer
constructor
A new instance of TestRunComparer.
Constructor Details
#initialize(test_run1, test_run2) ⇒ TestRunComparer
Returns a new instance of TestRunComparer.
8 9 10 11 |
# File 'app/interactors/test_run_comparer.rb', line 8 def initialize(test_run1, test_run2) @test_run1 = test_run1 @test_run2 = test_run2 end |
Instance Attribute Details
#test_run1 ⇒ Object (readonly)
Returns the value of attribute test_run1.
2 3 4 |
# File 'app/interactors/test_run_comparer.rb', line 2 def test_run1 @test_run1 end |
#test_run2 ⇒ Object (readonly)
Returns the value of attribute test_run2.
2 3 4 |
# File 'app/interactors/test_run_comparer.rb', line 2 def test_run2 @test_run2 end |
Class Method Details
.compare!(test_run1, test_run2) ⇒ Object
4 5 6 |
# File 'app/interactors/test_run_comparer.rb', line 4 def self.compare!(test_run1, test_run2) self.new(test_run1, test_run2).compare! end |
Instance Method Details
#compare! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/interactors/test_run_comparer.rb', line 13 def compare! return if test_run1.completed_without_running_tests? || test_run2.completed_without_running_tests? TestRun.transaction do each_comparison do |result_id, status1, status2| if status1.nil? TestResult.where(id: result_id).update_all(different: false, new_test: true) elsif status1 == status2 TestResult.where(id: result_id).update_all(different: false, new_test: false) else TestResult.where(id: result_id).update_all(different: true, new_test: false) end end test_run2.update_attribute :compared, true Houston.observer.fire "test_run:compared", test_run2 end end |
#each_comparison(&block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/interactors/test_run_comparer.rb', line 34 def each_comparison(&block) Test.connection.select_all(<<-SQL).rows.each(&block) SELECT test_results2.id, test_results1.status, test_results2.status FROM (SELECT * FROM test_results WHERE test_run_id=#{test_run2.id}) "test_results2" LEFT OUTER JOIN (SELECT * FROM test_results WHERE test_run_id=#{test_run1.id}) "test_results1" ON test_results1.test_id=test_results2.test_id SQL end |