forked from lujanfernaud/prevy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use time helpers in event_test.rb - Add WebMock - Refactor GroupsBreadcrumbsTest - Stub requests to maps.googleapis.com - Extract address utility method to test_helper.rb - Extract fake_event to test_helper.rb - Refactor NotificationsTest - Refactor GroupsShowTest - Extract groups utility methods to test_helper.rb - Refactor NotificationMailerTest - Refactor GroupsRolesTest - Extract attach_valid_image to test_helper.rb - Extract fill_in_description to test_helper.rb - Refactor UsersSignUpTest - Refactor GroupsSearchTest - Remove unnecessary GroupMembershipTest - Extract upload_valid_image to test_helper.rb
- Loading branch information
1 parent
73bb002
commit a7ff2a8
Showing
19 changed files
with
356 additions
and
384 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,27 @@ | ||
require 'test_helper' | ||
|
||
class EventDecoratorTest < ActiveSupport::TestCase | ||
def setup | ||
stub_requests_to_googleapis | ||
end | ||
|
||
test "#full_address returns full address without country" do | ||
event = fake_event | ||
event = fake_event_decorator | ||
full_address = "Obento, Matsubara-dori, 8, Kyoto, 6050856" | ||
|
||
assert_equal event.full_address, full_address | ||
end | ||
|
||
test "#short_address returns place name and city" do | ||
event = fake_event | ||
event = fake_event_decorator | ||
short_address = "Obento, Kyoto" | ||
|
||
assert_equal event.short_address, short_address | ||
end | ||
|
||
private | ||
|
||
def fake_event(params = {}) | ||
@fake_event ||= EventDecorator.new(Event.new( | ||
group: groups(:two), | ||
title: params[:title] || "Test event", | ||
description: params[:description] || Faker::Lorem.paragraph, | ||
website: params[:website] || "", | ||
start_date: params[:start_date] || Time.zone.now + 6.days, | ||
end_date: params[:end_date] || Time.zone.now + 1.week, | ||
image: params[:image] || image, | ||
organizer: users(:phil), | ||
address_attributes: address(params) | ||
)) | ||
end | ||
|
||
def image | ||
File.open(Rails.root.join('test/fixtures/files/sample.jpeg')) | ||
end | ||
|
||
def address(params = {}) | ||
{ | ||
place_name: params[:place_name] || "Obento", | ||
street1: params[:street1] || "Matsubara-dori, 8", | ||
street2: params[:street2] || "", | ||
city: params[:city] || "Kyoto", | ||
state: params[:state] || "", | ||
post_code: params[:post_code] || "6050856", | ||
country: params[:country] || "Japan" | ||
} | ||
def fake_event_decorator(params = {}) | ||
@fake_event_decorator ||= EventDecorator.new(fake_event(params)) | ||
end | ||
end |
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
Oops, something went wrong.