diff --git a/app/views/conversations/index.haml b/app/views/conversations/index.haml index a0f3d7fc2..d6a2e5885 100644 --- a/app/views/conversations/index.haml +++ b/app/views/conversations/index.haml @@ -20,27 +20,24 @@ .col-md-10 .list-group - @conversations.each do |conversation| - %a.list-group-item.list-group-item-action.flex-column.align-items-start{href: conversation_path(conversation)} - .d-flex.w-100.justify-content-between - %h5.mb-2.h5 - - if conversation.receipts_for(current_member).last.is_unread? - %i.far.fa-envelope.mr-4.pr-3 - - else - %i.far.fa-envelope-open.mr-4.pr-3 - %strong= conversation.subject - %small - #{time_ago_in_words conversation.messages.last.created_at} ago - %span.text-muted= conversation.messages.last.created_at - - %ul.list-group - - conversation.recipients.each do |member| - - if member != current_member - %li.member-chip - = image_tag(avatar_uri(member, 100), alt: '', height: 50, width: 50) - = member - - %p.mb-2 - = truncate(strip_tags(conversation.messages.last.body), length: 100, separator: ' ', omission: '... ') - Donec id elit non mi porta. + %a.list-group-item.list-group-item-action{href: conversation_path(conversation)} + .text-right.float-right + - conversation.recipients.each do |member| + - if member != current_member + .member-chip + = image_tag(avatar_uri(member, 100), alt: '', height: 50, width: 50) + = member + %h5.mb-2.h5 + - if conversation.receipts_for(current_member).last.is_unread? + = icon 'far', 'envelope' + - else + = icon 'far', 'envelope-open' + %strong= conversation.subject + %small + #{time_ago_in_words conversation.messages.last.created_at} ago + %span.text-muted= conversation.messages.last.created_at + %small= truncate(strip_tags(conversation.messages.last.body), length: 500, separator: ' ', omission: '... ') + .col-md-1 + = link_to delete_icon, conversation_path(conversation), class: 'btn text-danger' - unless @conversations.empty? = will_paginate @conversations diff --git a/spec/features/conversations/index_spec.rb b/spec/features/conversations/index_spec.rb index 72a75d13f..35f1107de 100644 --- a/spec/features/conversations/index_spec.rb +++ b/spec/features/conversations/index_spec.rb @@ -18,20 +18,7 @@ describe "Notifications", :js do it { expect(page).to have_content 'something i want to say' } it { Percy.snapshot(page, name: 'conversations#index') } - describe 'view conversation thread' do - before { click_link 'something i want to say' } - - it { expect(page).to have_content 'this is the body' } - it { expect(page).to have_link sender.login_name } - it { Percy.snapshot(page, name: 'conversations#show') } - - describe 'Replying to the conversation' do - before do - fill_in :body, with: 'i like this too' - click_button 'Send' - end - it { expect(page).to have_content "i like this too" } - end + describe 'deleting' do end end end diff --git a/spec/features/conversations/show_spec.rb b/spec/features/conversations/show_spec.rb new file mode 100644 index 000000000..8be150c0c --- /dev/null +++ b/spec/features/conversations/show_spec.rb @@ -0,0 +1,32 @@ +require 'rails_helper' + +describe "Notifications", :js do + let(:sender) { create :member } + let(:recipient) { create :member, login_name: 'beyonce' } + + before do + sender.send_message(recipient, "this is the body", "something i want to say") + login_as recipient + end + + describe 'view conversation thread' do + before do + visit root_path + click_link 'Your Stuff' + click_link 'Inbox' + click_link 'something i want to say' + end + + it { expect(page).to have_content 'this is the body' } + it { expect(page).to have_link sender.login_name } + it { Percy.snapshot(page, name: 'conversations#show') } + + describe 'Replying to the conversation' do + before do + fill_in :body, with: 'i like this too' + click_button 'Send' + end + it { expect(page).to have_content "i like this too" } + end + end +end diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb deleted file mode 100644 index dc149c7d9..000000000 --- a/spec/features/notifications_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'rails_helper' - -describe "Notifications", :js do - let(:sender) { create :member } - let(:recipient) { create :member, login_name: 'beyonce' } - - context "On existing notification" do - let!(:notification) do - create :notification, - sender: sender, - recipient: recipient, - body: "Notification body", - post_id: nil - end - - before do - login_as recipient - visit root_path - click_link 'Your Stuff' - Percy.snapshot(page, name: "notification menu") - visit notification_path(notification) - Percy.snapshot(page, name: "notifications#show") - end - - it "Replying to the notification" do - click_link "Reply" - expect(page).to have_content "Notification body" - Percy.snapshot(page, name: 'Replying to notification') - - fill_in 'notification_body', with: "Response body" - Percy.snapshot(page, name: "notifications#new") - click_button "Send" - - expect(page).to have_content "Message was successfully sent" - end - end - - describe 'pagination' do - before do - FactoryBot.create_list :notification, 34, recipient: recipient - login_as recipient - visit notifications_path - end - - it do - Percy.snapshot(page, name: "notifications#index") - end - - it 'has page navigation' do - expect(page).to have_selector 'a[rel="next"]' - end - - it 'paginates at 30 notifications per page' do - expect(page).to have_selector '.message', count: 30 - end - - it 'navigates pages' do - first('a[rel="next"]').click - expect(page).to have_selector '.message', count: 4 - end - end -end