Sha256: 3eec535e374794f68c9842a69f1eb77e1fd92b4e024ab10d63c9d55a22ad6f9f

Contents?: true

Size: 795 Bytes

Versions: 8

Compression:

Stored size: 795 Bytes

Contents

require 'spec_helper'

describe Redde::WithPhoto do
  let(:photo1) { Photo.create(src: '/uploads/1.txt', token: rand(1000)) }
  let(:photo2) { Photo.create(src: '/uploads/2.txt', token: rand(1000)) }
  let(:tokens) { [photo1.token, photo2.token] }
  let(:only_token) { { imageable_type: nil, imageable_id: nil, token: 123 } }
  let(:article) { Article.new(title: 'Test Title', photo_tokens: tokens) }

  it 'assigns photos to article' do
    Photo.delete_all
    article.save
    expect(article.photos.count).to eq 2
  end

  it 'it gets all photos for article' do
    Photo.delete_all
    article.save
    article.reload
    article.photos.first.update(only_token)
    article.photo_tokens = [123]
    expect(article.all_photos.count).to eq 2
    expect(article.photos.count).to eq 1
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
redde-0.1.18 spec/models/with_photo_spec.rb
redde-0.1.17 spec/models/with_photo_spec.rb
redde-0.1.16 spec/models/with_photo_spec.rb
redde-0.1.15 spec/models/with_photo_spec.rb
redde-0.1.14 spec/models/with_photo_spec.rb
redde-0.1.13 spec/models/with_photo_spec.rb
redde-0.1.12 spec/models/with_photo_spec.rb
redde-0.1.11 spec/models/with_photo_spec.rb