~cytrogen/masto-fe

ref: 685270f3f7ea6d4a8a48ec641e8fdfd9fc2e2d7f masto-fe/spec/support/examples/models/concerns/account_header.rb -rw-r--r-- 806 bytes
685270f3 — Claire [Glitch] Fix clicking “Explore” or “Live feeds” column headers to scroll in advanced mode 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

shared_examples 'AccountHeader' do |fabricator|
  describe 'base64-encoded files', paperclip_processing: true do
    let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
    let(:account) { Fabricate(fabricator, header: base64_attachment) }

    it 'saves header' do
      expect(account.persisted?).to be true
      expect(account.header).to_not be_nil
    end

    it 'gives the header a file name' do
      expect(account.header_file_name).to_not be_blank
    end

    it 'saves a new header under a different file name' do
      previous_file_name = account.header_file_name
      account.update(header: base64_attachment)
      expect(account.header_file_name).to_not eq previous_file_name
    end
  end
end