about summary refs log tree commit diff
path: root/spec/presenters
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-06-02 09:49:38 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-06-02 09:49:38 +0200
commit25a46d9e5999682f2a9bba3492f5497d1e0ce0bc (patch)
tree776495c28dcc1e75ceacdfcbe801ab7344978b88 /spec/presenters
parentc1d0a6a7981b5fe74bdd03c958a558096ea3cde8 (diff)
parent1485bd9b4bf407d1051a6b160d2530c9ca93f10b (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/javascript/styles/fonts/montserrat.scss`:
  Code style changes upstream, path changes in glitch-soc.
  Applied upstream's code style changes.
- `app/javascript/styles/fonts/roboto-mono.scss`:
  Code style changes upstream, path changes in glitch-soc.
  Applied upstream's code style changes.
- `app/javascript/styles/fonts/roboto.scss`:
  Code style changes upstream, path changes in glitch-soc.
  Applied upstream's code style changes.
- `app/models/account.rb`:
  Textual conflict only caused by glitch-soc using a different value
  for character limits in a nearby line.
  Applied upstream's changes.
- `app/views/statuses/_simple_status.html.haml`:
  Attribute added to a tag modified by glitch-soc.
  Added upstream's attributes.
- `yarn.lock`:
  Upstream added/updated dependencies close to glitch-soc-only ones.
  Updated/added upstream dependencies.
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/status_relationships_presenter_spec.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/presenters/status_relationships_presenter_spec.rb b/spec/presenters/status_relationships_presenter_spec.rb
new file mode 100644
index 000000000..03296bd17
--- /dev/null
+++ b/spec/presenters/status_relationships_presenter_spec.rb
@@ -0,0 +1,73 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe StatusRelationshipsPresenter do
+  describe '.initialize' do
+    before do
+      allow(Status).to receive(:reblogs_map).with(status_ids, current_account_id).and_return(default_map)
+      allow(Status).to receive(:favourites_map).with(status_ids, current_account_id).and_return(default_map)
+      allow(Status).to receive(:bookmarks_map).with(status_ids, current_account_id).and_return(default_map)
+      allow(Status).to receive(:mutes_map).with(anything, current_account_id).and_return(default_map)
+      allow(Status).to receive(:pins_map).with(anything, current_account_id).and_return(default_map)
+    end
+
+    let(:presenter)          { StatusRelationshipsPresenter.new(statuses, current_account_id, **options) }
+    let(:current_account_id) { Fabricate(:account).id }
+    let(:statuses)           { [Fabricate(:status)] }
+    let(:status_ids)         { statuses.map(&:id) }
+    let(:default_map)        { { 1 => true } }
+
+    context 'options are not set' do
+      let(:options) { {} }
+
+      it 'sets default maps' do
+        expect(presenter.reblogs_map).to    eq default_map
+        expect(presenter.favourites_map).to eq default_map
+        expect(presenter.bookmarks_map).to  eq default_map
+        expect(presenter.mutes_map).to      eq default_map
+        expect(presenter.pins_map).to       eq default_map
+      end
+    end
+
+    context 'options[:reblogs_map] is set' do
+      let(:options) { { reblogs_map: { 2 => true } } }
+
+      it 'sets @reblogs_map merged with default_map and options[:reblogs_map]' do
+        expect(presenter.reblogs_map).to eq default_map.merge(options[:reblogs_map])
+      end
+    end
+
+    context 'options[:favourites_map] is set' do
+      let(:options) { { favourites_map: { 3 => true } } }
+
+      it 'sets @favourites_map merged with default_map and options[:favourites_map]' do
+        expect(presenter.favourites_map).to eq default_map.merge(options[:favourites_map])
+      end
+    end
+
+    context 'options[:bookmarks_map] is set' do
+      let(:options) { { bookmarks_map: { 4 => true } } }
+
+      it 'sets @bookmarks_map merged with default_map and options[:bookmarks_map]' do
+        expect(presenter.bookmarks_map).to eq default_map.merge(options[:bookmarks_map])
+      end
+    end
+
+    context 'options[:mutes_map] is set' do
+      let(:options) { { mutes_map: { 5 => true } } }
+
+      it 'sets @mutes_map merged with default_map and options[:mutes_map]' do
+        expect(presenter.mutes_map).to eq default_map.merge(options[:mutes_map])
+      end
+    end
+
+    context 'options[:pins_map] is set' do
+      let(:options) { { pins_map: { 6 => true } } }
+
+      it 'sets @pins_map merged with default_map and options[:pins_map]' do
+        expect(presenter.pins_map).to eq default_map.merge(options[:pins_map])
+      end
+    end
+  end
+end