Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Add / modify specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuuleh committed Jun 8, 2018
1 parent 00c7699 commit d93cb3a
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/controllers/share/whatsapps_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative 'shared_examples'

describe Share::WhatsappsController do
include_examples 'shares', Share::Whatsapp, 'whatsapp'

let(:params) { { text: 'Bar' } }
let(:new_defaults) { { text: 'Foo {LINK}' } }
end
10 changes: 10 additions & 0 deletions spec/models/share/button_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: share_buttons
Expand Down Expand Up @@ -45,4 +46,13 @@
expect(button).to be_invalid
end
end

describe '.share_progress?' do
let(:facebook) { create :share_button, sp_type: 'facebook' }
let(:whatsapp) { create :share_button, sp_type: 'whatsapp' }
it 'returns true if the share type is managed by ShareProgress' do
expect(facebook.share_progress?).to eq true
expect(whatsapp.share_progress?).to eq false
end
end
end
8 changes: 8 additions & 0 deletions spec/models/share/email_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: share_emails
Expand Down Expand Up @@ -38,4 +39,11 @@
expect(subject).to_not be_valid
end
end

describe 'share_progress?' do
let(:email) { create(:share_email) }
it 'is managed by ShareProgress' do
expect(email.share_progress?).to eq true
end
end
end
8 changes: 8 additions & 0 deletions spec/models/share/facebook_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: share_facebooks
Expand Down Expand Up @@ -59,4 +60,11 @@
expect(share.reload.image).to eq nil
end
end

describe 'share_progress?' do
let(:facebook) { create(:share_facebook) }
it 'is managed by ShareProgress' do
expect(facebook.share_progress?).to eq true
end
end
end
8 changes: 8 additions & 0 deletions spec/models/share/twitter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: share_twitters
Expand Down Expand Up @@ -33,4 +34,11 @@
expect(subject).to_not be_valid
end
end

describe 'share_progress?' do
let(:twitter) { create(:share_twitter) }
it 'is managed by ShareProgress' do
expect(twitter.share_progress?).to eq true
end
end
end
43 changes: 43 additions & 0 deletions spec/models/share/whatsapp_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: share_whatsapps
#
# id :integer not null, primary key
# page_id :integer
# text :string
# button_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# click_count :integer
# share_count :integer

require 'rails_helper'

describe Share::Whatsapp do
describe 'validation' do
subject { build(:share_whatsapp) }

it 'is valid' do
expect(subject).to be_valid
end

it 'text must be present' do
subject.text = nil
expect(subject).to_not be_valid
end

it 'must have {LINK} in text' do
subject.text = 'Foo'
expect(subject).to_not be_valid
end
end

describe 'share_progress?' do
let(:whatsapp) { create(:share_whatsapp) }
it 'is not managed by ShareProgress' do
expect(whatsapp.share_progress?).to eq false
end
end
end

0 comments on commit d93cb3a

Please sign in to comment.