Created
December 16, 2015 01:58
-
-
Save koryteg/4310a0eb75efcec8b4c4 to your computer and use it in GitHub Desktop.
factory girl test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rails_helper" | |
RSpec.describe CampaignMailingTemplate, type: :template_object do | |
before(:all) do | |
# old factory girl code | |
# @entity = create(:entity) | |
# @campaign = create(:campaign, entity: @entity) | |
# @campaign_mailing = create(:campaign_manual_reminder, campaign: @campaign) | |
# @invitation = build(:invitation, guest: build(:user)) | |
create_entity | |
create_campaign | |
create_campaign_mailing | |
create_invitation | |
end | |
context "#campaign" do | |
it "should return campaign" do | |
@template_object = CampaignMailingTemplate.new(@campaign_mailing, @invitation) | |
expect(@template_object.campaign).to eq(@campaign) | |
end | |
end | |
context '#new' do | |
it 'should create an EmailStat' do | |
@template_object = CampaignMailingTemplate.new(@campaign_mailing, @invitation) | |
expect(@template_object.email_stat_id.class).to eq(String) | |
end | |
end | |
def create_entity | |
@entity = Entity.new(host: 'asdf.something.com', | |
name: 'entity_name') | |
@entity.save(validate: false) | |
@entity.reload | |
end | |
def create_campaign | |
@campaign = Campaign.new(name: 'new campaign', | |
entity: @entity) | |
@campaign.save(validate: false) | |
@campaign.reload | |
end | |
def create_campaign_mailing | |
@campaign_mailing = CampaignManualReminder.new( | |
campaign: @campaign, | |
subject: 'subject name') | |
end | |
def create_invitation | |
@invitation = Invitation.new(guest: User.new(first_name: 'laura')) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment