Skip to content

Commit

Permalink
fix failing #get_twitter_image helper specs
Browse files Browse the repository at this point in the history
  • Loading branch information
harunkumars committed Aug 26, 2023
1 parent 85e516b commit 67c8a71
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,30 @@
# end
# end
RSpec.describe ApplicationHelper, type: :helper do
describe 'application heler' do
context 'get_twitter_image method' do
describe 'application helper' do
# actual context: We realized just in time before RubyConfIndia2023 that due to Twitter API changes
# we are unable to retrieve profile pictures for new twitter sign_ups through Cloudinary

context 'get_twitter_image for User who last signed in before RubyIndiaConf 2023' do
it 'should render image tag with the twitter handle' do
twitter_handle = 'foobar'
expect(helper.get_twitter_image(twitter_handle)).to match("#{twitter_handle}\.jpg")
user = User.new(twitter_handle: 'my_twitter_handle', updated_at: Date.parse('2022-12-31').end_of_day)
expect(helper.get_twitter_image(user)).to match("cloudinary.*my_twitter_handle\.jpg")
end
end
context 'get_twitter_image for User who last signed in after RubyIndiaConf 2023' do
it 'should render image tag with twitter handle (in the unlikely case, our User model does not contain the image url)' do
user = User.new(twitter_handle: 'my_twitter_handle', updated_at: Date.parse('2024-01-01').end_of_day)
expect(helper.get_twitter_image(user)).to match("cloudinary.*my_twitter_handle\.jpg")
end
it 'should render image tag using the URL saved on the User model' do
user = User.new(
twitter_handle: 'my_twitter_handle',
image: 'https://pbs.twimg.com/profile_images/123456789/my_selfie.jpg',
updated_at: Date.parse('2024-01-01').end_of_day
)
image_url = helper.get_twitter_image(user)
expect(image_url).to_not match("my_twitter_handle\.jpg")
expect(image_url).to match("my_selfie\.jpg")
end
end
end
Expand Down

0 comments on commit 67c8a71

Please sign in to comment.