Skip to content

Commit

Permalink
created a seperate scenario for edit reason
Browse files Browse the repository at this point in the history
  • Loading branch information
a-c-sreedhar-reddy committed Oct 9, 2020
1 parent 00260fb commit a66c11f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/views/posts/versions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<% if version.reason? %>
<div class="mt-1 text-xs">
<span class="font-semibold">Reason:</span>
<span><%= @post.edit_reason %></span>
<span><%= version.reason %></span>
</div>
<% end %>
</div>
Expand Down
36 changes: 34 additions & 2 deletions spec/system/community/community_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,40 @@
expect(community.topics.reload.find_by(title: topic_title).first_post.body).to eq(topic_body)
end

scenario 'a student edits her post and leaves a reason' do
sign_in_user(student_2.user, referrer: community_path(community))
click_link topic_1.title
replace_markdown reply_body
click_button 'Post Your Reply'
dismiss_notification
new_reply = topic_1.reload.replies.last

# Edit a reply and set reason first time.
find("div[aria-label='Options for post #{new_reply.id}']").click
click_button 'Edit Reply'
within("div#post-show-#{new_reply.id}") do
replace_markdown reply_body_for_edit
end
fill_in 'edit-reason', with: 'Test Edit Reason'
click_button 'Update Reply'

# Edit a reply and set reason second time.
find("div[aria-label='Options for post #{new_reply.id}']").click
click_button 'Edit Reply'
within("div#post-show-#{new_reply.id}") do
replace_markdown reply_body_for_edit
end
fill_in 'edit-reason', with: 'Test Edit Reason second time'
click_button 'Update Reply'

# Go to the history page history - the reason should be there.
find("div[aria-label='Options for post #{new_reply.id}']").click
click_link 'History'

expect(page).to have_text('Test Edit Reason')
expect(page).to have_text('Test Edit Reason second time')
end

scenario 'an active student participates in a topic thread' do
sign_in_user(student_2.user, referrer: community_path(community))
expect(page).to have_text(community.name)
Expand Down Expand Up @@ -108,7 +142,6 @@
within("div#post-show-#{new_reply.id}") do
replace_markdown reply_body_for_edit
end
fill_in 'edit-reason', with: 'Test Edit Reason'
click_button 'Update Reply'

expect(page).not_to have_text(reply_body)
Expand All @@ -121,7 +154,6 @@
expect(page).to have_text('Post Edit History')
expect(page).to have_text(reply_body)
expect(page).to have_text(reply_body_for_edit)
expect(page).to have_text('Test Edit Reason')
click_link 'Back to Post'

# can archive his reply
Expand Down

0 comments on commit a66c11f

Please sign in to comment.