Merge branch 'use_sequence_for_factory_ids' into 'master'

Use sequence for factory ids

Factory objects should be as similar as possible to valid objects after creation.
This MR adds the id field to all the factories as a sequence, allowing multiple objects to be built but without the same id.

See merge request !31
parents cdb7cf54 769cb917
Pipeline #3700424 passed with stage
in 9 minutes and 11 seconds
......@@ -32,7 +32,7 @@ RSpec.describe ContentsController, type: :controller do
end
describe 'GET #show' do
let(:video) { build(:video, :with_file_name, id: 1) }
let(:video) { build(:video, :with_file_name) }
let(:encoded_video) { build(:encoded_video) }
context 'video found' do
......
......@@ -44,7 +44,7 @@ RSpec.describe ProfilesController, type: :controller do
end
describe 'GET #show' do
let(:profile) { build(:profile, id: 1) }
let(:profile) { build(:profile) }
context 'profile found' do
before do
expect(Profile).to receive(:find).with(profile.id.to_s).and_return(profile)
......@@ -90,7 +90,7 @@ RSpec.describe ProfilesController, type: :controller do
end
describe "PUT #update" do
let(:profile) { build(:profile, id: 1) }
let(:profile) { build(:profile) }
before do
expect(Profile).to receive(:find).with(profile.id.to_s).and_return profile
......@@ -124,7 +124,7 @@ RSpec.describe ProfilesController, type: :controller do
end
describe "DELETE #destroy" do
let(:profile) { build(:profile, id: 1) }
let(:profile) { build(:profile) }
before do
expect(Profile).to receive(:find).with(profile.id.to_s).and_return profile
......
FactoryGirl.define do
factory :video, class: Content do
sequence(:id, 1)
title 'Video Title'
zip_code '00000-000'
soundtrack 'soundtrack'
......
FactoryGirl.define do
factory :encoded_video, class: EncodedContent do
sequence(:id, 1)
output_id 1
state 'finished'
width 640
......
FactoryGirl.define do
factory :profile do
sequence(:id, 1)
first_name 'Media'
country 'BR'
city 'Sao Paulo'
......@@ -18,6 +19,7 @@ FactoryGirl.define do
end
factory :another_profile, class: Profile do
sequence(:id, 1)
first_name "Name"
country "BR"
city "Rio de Janeiro"
......
FactoryGirl.define do
factory :user do
sequence(:id, 1)
sequence :email do |n|
"email#{n}@email.com"
end
......
......@@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe RequestZencoderJob, type: :job do
describe 'perform' do
let(:video) { build(:video, id: 1 ) }
let(:video) { build(:video) }
let(:response_body) { { 'id' => 12 } }
let(:response) { instance_double('response') }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment