aboutsummaryrefslogtreecommitdiff
blob: e4b48b670404010a134b2bef60b75b2566d68733 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Given /^some council members$/ do
  (1..8).each do |n|
    u = User.new
    u.name = "Member no #{n}"
    u.email = "member-#{n}@example.com"
    u.irc_nick = "member-#{n}"
    u.password = "Example"
    u.council_member = true
    u.save!
  end
end

Given /^I am logged in as council member$/ do
  When 'I am on the login page'
  When 'I fill in "login" with "member-1@example.com"'
  When 'I fill in "password" with "Example"'
  When 'I press "Login"'
end

When /^application got voting results from IRC bot$/ do
  Participation.mark_participations({ 'Some item' =>
    { User.first.irc_nick => 'Some vote',
      User.last.irc_nick => 'Some other vote' } })
end

Then /^I should see some council members as participants$/ do
  Then "I should see \"#{User.first.name}\" within \".collection.participations.participations-collection\""
  Then "I should see \"#{User.last.name}\" within \".collection.participations.participations-collection\""
end

Given /^some agendas$/ do
  for i in 1..11
    Factory(:agenda, :state => 'old', :meeting_time => i.months.ago)
  end
  Factory(:agenda)
end

Given /^some council members who attended properly$/ do
  users = users_factory([:council]*3)
  for a in Agenda.all
    for u in users
      Factory(:participation, :participant => u, :agenda => a)
    end
  end
end

Given /^some council members who skipped last meeting$/ do
  users = users_factory([:council]*3)
  for a in Agenda.all - [Agenda.last]
    for u in users
      Factory(:participation, :participant => u, :agenda => a)
    end
  end
end

Given /^some slackers$/ do
  users = users_factory([:council]*3)
  i = 0
  for a in Agenda.all
    next if i < 2
    for u in users
      Factory(:participation, :participant => u, :agenda => a)
    end
  end
end

Given /^some slackers who skipped a meeting$/ do
  users = users_factory([:council]*3)
  i = 0
  for a in Agenda.all - [Agenda.last]
    next if i < 2
    for u in users
      Factory(:participation, :participant => u, :agenda => a)
    end
  end
end

Given /^council term started a year ago$/ do
  CustomConfig['CouncilTerm']['start_time'] = 1.year.ago
end

Then /^I should see list of all council members with proper indication of their attendance$/ do
  start = CustomConfig['CouncilTerm']['start_time']
  stop = Agenda.current.meeting_time - 1.minute
  for user in User.council_member_is(true)
    Then "I should see \"#{user.name} - #{user.slacking_status_in_period(start, stop)}\" within \".collection.slacking-statuses\""
  end
end