• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codebar / planner / 24966061628

26 Apr 2026 08:16PM UTC coverage: 95.058% (-0.4%) from 95.443%
24966061628

Pull #2596

github

web-flow
Merge 105c8567d into fd1a03b79
Pull Request #2596: Speed up test execution via fabricator optimizations

9 of 20 new or added lines in 3 files covered. (45.0%)

4 existing lines in 1 file now uncovered.

3520 of 3703 relevant lines covered (95.06%)

39.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.94
/app/models/event.rb
1
class Event < ApplicationRecord
6✔
2
  include DateTimeConcerns
6✔
3
  include Listable
6✔
4
  include Invitable
6✔
5
  include EventHelper
6✔
6

7
  attr_accessor :local_date, :local_time, :local_end_time
6✔
8

9
  resourcify :permissions, role_cname: 'Permission', role_table_name: :permission
6✔
10

11
  belongs_to :venue, class_name: 'Sponsor', optional: true
6✔
12
  has_many :sponsorships
6✔
13
  has_many :sponsors, -> { where('sponsorships.level' => nil) }, through: :sponsorships, source: :sponsor
271✔
14
  has_many :bronze_sponsors, -> { where('sponsorships.level' => 'bronze') }, through: :sponsorships, source: :sponsor
155✔
15
  has_many :silver_sponsors, -> { where('sponsorships.level' => 'silver') }, through: :sponsorships, source: :sponsor
155✔
16
  has_many :gold_sponsors, -> { where('sponsorships.level' => 'gold') }, through: :sponsorships, source: :sponsor
155✔
17
  has_many :organisers, -> { where('permissions.name' => 'organiser') }, through: :permissions, source: :members
233✔
18
  has_and_belongs_to_many :chapters, join_table: 'chapters_events'
6✔
19
  has_many :invitations
6✔
20

21
  validates :name, :slug, :info, :schedule, :description, presence: true
6✔
22
  validates :slug, uniqueness: true
6✔
23
  validate :invitability, if: :invitable?
6✔
24
  validates :coach_spaces, :student_spaces, numericality: true
6✔
25
  validate :sponsors_uniqueness
6✔
26
  validate :bronze_sponsors_uniqueness
6✔
27
  validate :silver_sponsors_uniqueness
6✔
28
  validate :gold_sponsors_uniqueness
6✔
29
  validate :venue_or_remote_must_be_present
6✔
30
  validates :date_and_time, :ends_at, presence: true
6✔
31

32
  before_validation :set_date_and_time, :set_end_date_and_time
6✔
33

34
  def to_s
6✔
35
    name
74✔
36
  end
37

38
  def to_param
6✔
39
    slug
147✔
40
  end
41

42
  def verified_coaches
6✔
43
    invitations.coaches.accepted.verified.map(&:member)
28✔
44
  end
45

46
  def verified_students
6✔
47
    invitations.students.accepted.verified.map(&:member)
10✔
48
  end
49

50
  def coaches_only?
6✔
51
    student_spaces.zero?
12✔
52
  end
53

54
  def students_only?
6✔
55
    coach_spaces.zero?
12✔
56
  end
57

58
  def coach_spaces?
6✔
59
    !students_only? && coach_spaces > attending_coaches.count
5✔
60
  end
61

62
  def student_spaces?
6✔
63
    !coaches_only? && student_spaces > attending_students.count
5✔
64
  end
65

66
  def invitability
6✔
67
    errors.add(:coach_spaces, :required) if coach_spaces.blank?
161✔
68
    errors.add(:student_spaces, :required) if student_spaces.blank?
161✔
69
    errors.add(:invitable, :all_invitation_details_required) \
70
      if coach_spaces.blank? || student_spaces.blank?
161✔
71
  end
72

73
  def student_emails
6✔
74
    invitations.students.where(attending: true).map { |i| i.member.email }
2✔
75
  end
76

77
  def coach_emails
6✔
78
    invitations.coaches.where(attending: true).map { |i| i.member.email }
2✔
79
  end
80

81
  def permitted_audience_values
6✔
82
    %w[Students Coaches]
4✔
83
  end
84

85
  def sponsors?(level = nil)
6✔
86
    case level
36✔
UNCOV
87
    when :gold then gold_sponsors.any?
×
UNCOV
88
    when :silver then silver_sponsors.any?
×
UNCOV
89
    when :bronze then bronze_sponsors.any?
×
UNCOV
90
    when :standard then sponsors.any?
×
91
    else sponsorships.any?
36✔
92
    end
93
  end
94

95
  private
6✔
96

97
  def duplicated_sponsors
6✔
98
    @duplicated_sponsors ||= fetch_duplicated_sponsors
660✔
99
  end
100

101
  def fetch_duplicated_sponsors
6✔
102
    ids = sponsorships.reject(&:marked_for_destruction?).map(&:sponsor_id)
146✔
103
    ids.select { |e| ids.count(e) > 1 }
146✔
104
  end
105
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc