Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
use helper instead of decorator
Browse files Browse the repository at this point in the history
Probably, decorator can not successfully generate the `url`
  • Loading branch information
y-yagi committed Jun 15, 2015
1 parent 415e826 commit 2e17bb9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ def create_route_title_from_schedules(schedules, index)
end
route_title + '〜' + schedules[index].place.name
end

def generate_invite_url(travel)
new_travel_member_url(travel_id: travel.id, key: travel.generate_invite_key)
end
end
2 changes: 1 addition & 1 deletion app/views/travels/_member.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.panel-body
| この旅行計画にメンバーを追加したい場合、以下のURLをメンバーにシェアして下さい。
br
= text_field_tag(:invite_url, @travel.generate_invite_url, { readonly: true, class: 'form-control' })
= text_field_tag(:invite_url, generate_invite_url(@travel), { readonly: true, class: 'form-control' })

br
hr
Expand Down
2 changes: 0 additions & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,3 @@
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

Rails.application.default_url_options[:host] = 'localhost:3000'
2 changes: 0 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,3 @@
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

Rails.application.default_url_options[:host] = 'travel-base.herokuapp.com'
2 changes: 0 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@
# config.action_view.raise_on_missing_translations = true
config.active_support.test_order = :random
end

Rails.application.default_url_options[:host] = 'www.example.com'
8 changes: 6 additions & 2 deletions test/integration/travel_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ def setup
click_link 'メンバー管理'

invite_url = find('#invite_url').value
assert_equal travel.generate_invite_url, invite_url
expect_invite_url = new_travel_member_url(
travel_id: travel.id, key: travel.generate_invite_key)
assert_equal expect_invite_url, invite_url
end

test 'can add member' do
Expand All @@ -192,7 +194,9 @@ def setup
other_user_travel = Travel.mine(twitter_user).first

assert_not_includes other_user_travel.members, current_user.id
visit other_user_travel.generate_invite_url
invite_url = new_travel_member_url(
travel_id: other_user_travel.id, key: other_user_travel.generate_invite_key)
visit invite_url
other_user_travel.reload
assert_includes other_user_travel.members, current_user.id
end
Expand Down

0 comments on commit 2e17bb9

Please sign in to comment.