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

MushroomObserver / mushroom-observer / 19215827749

09 Nov 2025 11:06PM UTC coverage: 95.046% (+0.02%) from 95.027%
19215827749

push

github

web-flow
Merge pull request #3409 from MushroomObserver/nimmo-phlex-interactive-image

Migrate `matrix_box`, `interactive_image` and `carousel` helpers to new Phlex components

855 of 878 new or added lines in 22 files covered. (97.38%)

9 existing lines in 2 files now uncovered.

29543 of 31083 relevant lines covered (95.05%)

691.62 hits per line

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

92.73
/app/components/matrix_box/render_data.rb
1
# frozen_string_literal: true
2

3
class Components::MatrixBox
1✔
4
  # Build render data for MatrixBox based on @object type
5
  module RenderData
1✔
6
    def build_render_data
1✔
7
      case @object
4,613✔
8
      when ::Image
9
        extract_image_data
413✔
10
      when Observation
11
        extract_observation_data
3,472✔
12
      when RssLog
13
        extract_rss_log_data
421✔
14
      when User
15
        extract_user_data
307✔
16
      else
NEW
17
        { id: @object.id, type: :unknown }
×
18
      end
19
    end
20

21
    def extract_image_data
1✔
22
      {
23
        id: @object.id,
413✔
24
        type: :image,
25
        when: begin
26
                @object.when.web_date
413✔
27
              rescue StandardError
NEW
28
                nil
×
29
              end,
30
        who: @object.user,
31
        name: @object.unique_format_name.t,
32
        what: @object,
33
        where: nil,
34
        location: nil,
35
        image: @object,
36
        image_link: @object.show_link_args,
37
        full_width: true
38
      }
39
    end
40

41
    def extract_observation_data # rubocop:disable Metrics/AbcSize
1✔
42
      data = {
43
        id: @object.id,
3,472✔
44
        type: :observation,
45
        when: @object.when.web_date,
46
        who: @object.user,
47
        name: @object.user_format_name(@object.user).t.break_name.small_author,
48
        what: @object,
49
        where: @object.where,
50
        location: @object.location,
51
        consensus: Observation::NamingConsensus.new(@object),
52
        detail: @object.rss_log&.detail,
53
        time: @object.rss_log&.updated_at
54
      }
55

56
      add_observation_image_data(data) if @object.thumb_image_id
3,472✔
57
      data
3,472✔
58
    end
59

60
    def add_observation_image_data(data)
1✔
61
      data[:image] = @object.thumb_image
365✔
62
      data[:image_link] = @object.show_link_args
365✔
63
      data[:obs] = @object
365✔
64
      data[:full_width] = true
365✔
65
    end
66

67
    def extract_rss_log_data
1✔
68
      target = @object.target
421✔
69
      data = {
70
        id: target&.id || @object.id,
421✔
71
        type: @object.target_type || :rss_log,
72
        when: target.respond_to?(:when) ? target.when&.web_date : nil,
421✔
73
        who: target&.user,
74
        what: target || @object,
75
        detail: @object.detail,
76
        time: @object.updated_at
77
      }
78

79
      data[:name] = extract_rss_log_name(target)
421✔
80
      add_rss_log_location_data(data, target)
421✔
81
      add_rss_log_image_data(data, target)
421✔
82
      data
421✔
83
    end
84

85
    def extract_rss_log_name(target)
1✔
86
      if @object.target_type == :image
421✔
NEW
87
        target.unique_format_name.t
×
88
      elsif target
421✔
89
        target.format_name.t.break_name.small_author
421✔
90
      else
NEW
91
        @object.format_name.t.break_name.small_author
×
92
      end
93
    end
94

95
    def add_rss_log_location_data(data, target)
1✔
96
      return unless target.respond_to?(:location)
421✔
97

98
      data[:where] = target.where
384✔
99
      data[:location] = target.location
384✔
100
    end
101

102
    def add_rss_log_image_data(data, target)
1✔
103
      return unless target.respond_to?(:thumb_image) && target&.thumb_image
421✔
104

105
      data[:image] = target.thumb_image
115✔
106
      data[:image_link] = target.show_link_args
115✔
107
      data[:obs] = target if target.respond_to?(:is_collection_location)
115✔
108
      data[:full_width] = true
115✔
109
    end
110

111
    def extract_user_data
1✔
112
      data = {
113
        id: @object.id,
307✔
114
        type: :user,
115
        detail: @object,
116
        name: @object.unique_text_name,
117
        what: @object,
118
        where: @object.location&.name,
119
        location: @object.location
120
      }
121

122
      add_user_image_data(data) if @object.image_id
307✔
123
      data
307✔
124
    end
125

126
    def add_user_image_data(data)
1✔
127
      data[:image] = @object.image
3✔
128
      data[:image_link] = @object.show_link_args
3✔
129
      data[:votes] = false
3✔
130
      data[:full_width] = true
3✔
131
    end
132
  end
133
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