Skip to content

Commit e2db193

Browse files
committed
Fixing rpsec failures
1 parent ee13841 commit e2db193

4 files changed

Lines changed: 13 additions & 48 deletions

File tree

app/controllers/topics_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def index
2323
def show
2424
messages_scope = @topic.messages.includes(:sender, reply_to: :sender)
2525

26-
@view_mode = 'flat'
27-
@sort_order = :asc
28-
@messages = messages_scope.order(created_at: @sort_order)
26+
@messages = messages_scope.order(created_at: :asc)
2927
@message_numbers = @messages.each_with_index.to_h { |msg, idx| [msg.id, idx + 1] }
3028
preload_read_state!
3129
auto_mark_aware!

app/views/topics/show.html.slim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@
9999
.thread-notes-container
100100
= render "notes/note_stack", topic: @topic, message: nil, notes: thread_notes
101101

102-
.messages-container class=(["messages-container", @view_mode, (@sort_order == :desc ? "desc" : "asc")].compact.join(" "))
102+
.messages-container.flat.asc
103103
- if user_signed_in?
104104
.thread-actions data-controller="thread-actions" data-thread-actions-topic-id-value=@topic.id data-thread-actions-read-all-url-value=read_all_topic_path(@topic, format: :json)
105105
button.button-secondary data-action="click->thread-actions#markAllRead" Mark all messages read
106106

107107
- @messages.each do |message|
108-
= render 'message', message: message, view_mode: 'flat', number: @message_numbers[message.id]
108+
= render 'message', message: message, number: @message_numbers[message.id]
109109

110110
.topic-navigation
111111
= link_to "← Back to Topics", topics_path, class: "back-link"

config/environments/test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
config.action_mailer.delivery_method = :test
3838

3939
# Set host to be used by links generated in mailer templates.
40-
config.action_mailer.default_url_options = { host: "example.com" }
40+
config.action_mailer.default_url_options = { host: "hackorum.dev" }
41+
42+
# Default from address for all mailers
43+
config.action_mailer.default_options = {
44+
from: "noreply@hackorum.dev"
45+
}
4146

4247
# Print deprecation notices to the stderr.
4348
config.active_support.deprecation = :stderr

spec/requests/topics_spec.rb

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -73,51 +73,13 @@
7373
expect(response.body).to include(reply_message.body)
7474
end
7575

76-
it "shows threaded view by default" do
76+
it "shows flat view (oldest first)" do
7777
get topic_path(topic)
78-
expect(response.body).to include('messages-container threaded')
79-
end
80-
81-
it "has active Threaded button" do
82-
get topic_path(topic)
83-
expect(response.body).to include('class="toggle-btn active"')
84-
end
85-
86-
it "has active Oldest First button" do
87-
get topic_path(topic)
88-
expect(response.body).to include('class="toggle-btn active"')
89-
end
90-
end
91-
92-
context "with flat view mode" do
93-
it "shows flat view" do
94-
get topic_path(topic, view: 'flat')
95-
expect(response).to have_http_status(:success)
9678
expect(response.body).to include('messages-container flat')
97-
end
98-
99-
it "has active Flat button" do
100-
get topic_path(topic, view: 'flat')
101-
expect(response.body).to include('toggle-btn active')
102-
end
103-
end
104-
105-
context "with descending sort" do
106-
it "shows newest first" do
107-
get topic_path(topic, view: 'flat', sort: 'desc')
108-
expect(response).to have_http_status(:success)
109-
# Check that reply message appears before root message in HTML
110-
reply_position = response.body.index(reply_message.body)
79+
# root should appear before reply
11180
root_position = response.body.index(root_message.body)
112-
expect(reply_position).to be < root_position
113-
end
114-
end
115-
116-
context "with invalid view mode" do
117-
it "defaults to threaded" do
118-
get topic_path(topic, view: 'invalid')
119-
expect(response).to have_http_status(:success)
120-
expect(response.body).to include('messages-container threaded')
81+
reply_position = response.body.index(reply_message.body)
82+
expect(root_position).to be < reply_position
12183
end
12284
end
12385

0 commit comments

Comments
 (0)