Module: Gerd::Inspections::Organisation

Defined in:
lib/gerd/inspections/diffs/organisation.rb,
lib/gerd/inspections/actions/update_name_action.rb

Defined Under Namespace

Modules: Actions Classes: Diff

Class Method Summary collapse

Class Method Details

.inspect_expected_teams_exist(expected, actual) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gerd/inspections/diffs/organisation.rb', line 32

def self.inspect_expected_teams_exist(expected, actual)

  diffs = []

  expected_teams = expected.teams
  actual_teams = actual.teams

  expected_teams.keys.each do | expected_team |
    if !actual_teams.keys.include? expected_team
      team_to_create = expected_teams[expected_team]
      action = Gerd::Inspections::Actions::CreateTeam.new(expected_team, expected.organisation, team_to_create)
      diffs << Gerd::Inspections::Diff.new(false, "I expected to see team #{expected_team} but did not", [action])
    end

  end

  diffs.flatten

end

.inspect_no_extra_teams_exist(expected, actual) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/gerd/inspections/diffs/organisation.rb', line 52

def self.inspect_no_extra_teams_exist(expected, actual)

  diffs = []

  expected_teams = expected.teams
  actual_teams = actual.teams

  actual_teams.keys.each do | team |

    if !expected_teams.keys.include? team

      action = Gerd::Inspections::Actions::DeleteTeam.new(actual_teams[team])
      diffs << Gerd::Inspections::Diff.new(false, "I did not expect to see team #{team} but saw it anyway", [action])
    end

  end

  diffs

end

.inspect_organisations(expected, actual) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gerd/inspections/diffs/organisation.rb', line 10

def self.inspect_organisations(expected, actual)
  if expected.organisation == actual.organisation
     return Gerd::Inspections::Organisation::Diff.new(true, "Organisations match")
   else
     action = Gerd::Inspections::Organisation::Actions::UpdateName.new(expected, actual) 
     return Gerd::Inspections::Organisation::Diff.new(
      false, "Expected #{expected.organisation} but found #{actual.organisation}",
      [action]
      )
  end
end

.inspect_teams(expected, actual) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/gerd/inspections/diffs/organisation.rb', line 22

def self.inspect_teams(expected, actual)
  diffs = []

  diffs << inspect_expected_teams_exist(expected, actual)

  diffs << inspect_no_extra_teams_exist(expected, actual)

  diffs.flatten
end