-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
381 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
.space-t { | ||
margin-top: 2rem; | ||
} | ||
.space-b { | ||
margin-bottom: 2rem; | ||
} | ||
|
||
.no-m { | ||
margin: 0; | ||
|
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,2 +1,18 @@ | ||
module WalksHelper | ||
def walks_public_status_helper(walk) | ||
walk_status = 'walk' | ||
if walk.stations.present? && walk.stations.count >= 2 | ||
walk_status = 'station' | ||
if walk.courseline.present? | ||
walk_status = 'courseline' | ||
if walk.stations.first.subjects.present? | ||
walk_status = 'subject' | ||
if walk.stations.first.subjects.first.pages.present? | ||
walk_status = 'page' | ||
end | ||
end | ||
end | ||
end | ||
walk_status | ||
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
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<div class="container space-b walk-publish-container"> | ||
<div class="columns"> | ||
<% if @walk.publishable? %> | ||
<div class="column col-6 col-md-10 col-mx-auto box"> | ||
<div class="columns"> | ||
<div class="column col-10"> | ||
<p class="va-middle m-2"><%= t('walk.publish.can') %></p> | ||
</div> | ||
<div class="column col-2 text-right"> | ||
<%= render "walks/publish"%> | ||
</div> | ||
</div> | ||
</div> | ||
<% else %> | ||
<div class="column col-12 box"> | ||
<p class="mt-2"><%= t('walk.publish.cannot') %></p> | ||
<ul class="step mt-2 mb-2"> | ||
<li class="step-item <%= 'active' if walks_public_status_helper(@walk) == 'walk' %>"> | ||
<%= link_to t('walk.singular'), walk_path(@walk), | ||
data: { tooltip: t('walk.publish.step_walk') }, | ||
class: "tooltip"%> | ||
</li> | ||
|
||
<li class="step-item <%= 'active' if walks_public_status_helper(@walk) == 'station' %>"> | ||
<%= link_to t('station.singular'), new_walk_station_path(@walk), | ||
data: { tooltip: t('walk.publish.step_station') }, | ||
class: "tooltip"%> | ||
</li> | ||
|
||
<li class="step-item <%= 'active' if walks_public_status_helper(@walk) == 'courseline' %>"> | ||
<% if @walk.stations.count >= 2 %> | ||
<%= link_to t('walk.course.name'), route_walk_path(@walk), | ||
data: { tooltip: t('walk.publish.step_course') }, | ||
class: "tooltip"%> | ||
<% else %> | ||
<a disabled="disabled" class="tooltip" | ||
data-tooltip="<%= t('walk.publish.step_course')%>"><%= t('walk.course.name')%></a> | ||
<% end %> | ||
</li> | ||
|
||
<li class="step-item <%= 'active' if walks_public_status_helper(@walk) == 'subject' %>"> | ||
<% if @walk.stations.first.present? %> | ||
<%= link_to t('subject.singular'), new_station_subject_path(@walk.stations.first), | ||
data: { tooltip: t('walk.publish.step_subject') }, | ||
class: "tooltip"%> | ||
<% else %> | ||
<a disabled="disabled" class="tooltip" | ||
data-tooltip="<%= t('walk.publish.step_subject')%>"><%= t('subject.singular') %></a> | ||
<% end %> | ||
</li> | ||
|
||
<li class="step-item <%= 'active' if walks_public_status_helper(@walk) == 'page' %>"> | ||
<% if @walk.stations.first.present? && @walk.stations.first.subjects.first.present? %> | ||
<%= link_to t('page.singular'), new_subject_page_path(@walk.stations.first.subjects.first), | ||
data: { tooltip: t('walk.publish.step_page') }, | ||
class: "tooltip"%> | ||
<% else %> | ||
<a disabled="disabled" class="tooltip" | ||
data-tooltip="<%= t('walk.publish.step_page') %>"><%= t('page.singular') %></a> | ||
<% end %> | ||
</li> | ||
</ul> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= form_for :walk, method: :patch, url: walk_path(@walk), html: { class: 'd-inline' } do |f| %> | ||
<%= f.hidden_field :public %> | ||
<button class="btn btn-secondary tooltip" | ||
data-tooltip="<%= t('walk.publish.btn_tooltip')%>"><i data-feather="globe"></i></button> | ||
<% 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
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 |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# coding: utf-8 | ||
require 'rails_helper' | ||
|
||
RSpec.feature 'Publish a walk', type: :feature do | ||
context 'with a fresh walk' do | ||
let!(:user) { FactoryBot.create(:user) } | ||
let!(:walk) { FactoryBot.create(:walk, user: user) } | ||
|
||
scenario 'click on station link', js: true do | ||
sign_in user | ||
visit "/en/walks/#{walk.id}" | ||
within '.walk-container' do | ||
expect(page).to have_content(walk.name) | ||
end | ||
expect(page).to have_selector('.walk-publish-container') | ||
expect(page).to have_content I18n.t('walk.publish.cannot') | ||
|
||
within '.walk-publish-container' do | ||
expect(page).to have_selector('.step-item:first-of-type.active') | ||
expect(page).to_not have_selector('.step-item:nth-of-type(3) a:not([disabled])') | ||
click_link('Station') | ||
end | ||
expect(page).to have_content(I18n.t('station.new')) | ||
|
||
end | ||
end | ||
|
||
context 'with a walk with stations' do | ||
let!(:user) { FactoryBot.create(:user) } | ||
let!(:walk) { FactoryBot.create(:walk, user: user) } | ||
let!(:stations) { FactoryBot.create_list(:station, 2, | ||
user: user, | ||
walk_id: walk.id, | ||
next: 1) } | ||
|
||
scenario 'click on route link', js: true do | ||
sign_in user | ||
visit "/en/walks/#{walk.id}" | ||
expect(page).to have_content I18n.t('walk.publish.cannot') | ||
|
||
within '.walk-publish-container' do | ||
expect(page).to have_selector('.step-item:nth-of-type(2).active') | ||
expect(page).to have_selector('.step-item:nth-of-type(4) a:not([disabled])') | ||
expect(page).to_not have_selector('.step-item:nth-of-type(5) a:not([disabled])') | ||
click_link('Route') | ||
end | ||
expect(page).to have_content(I18n.t('walk.course.label')) | ||
end | ||
end | ||
|
||
context 'with a walk with courseline' do | ||
let!(:user) { FactoryBot.create(:user) } | ||
let!(:walk) { FactoryBot.create(:walk, | ||
user: user, | ||
courseline: [[12, 12], [12.1, 12]]) } | ||
let!(:stations) { FactoryBot.create_list(:station, 2, | ||
user: user, | ||
walk_id: walk.id, | ||
next: 1) } | ||
|
||
scenario 'click on subject link', js: true do | ||
sign_in user | ||
visit "/en/walks/#{walk.id}" | ||
expect(page).to have_content I18n.t('walk.publish.cannot') | ||
|
||
within '.walk-publish-container' do | ||
expect(page).to have_selector('.step-item:nth-of-type(3).active') | ||
expect(page).to have_selector('.step-item:nth-of-type(4) a:not([disabled])') | ||
expect(page).to_not have_selector('.step-item:nth-of-type(5) a:not([disabled])') | ||
click_link('Subject') | ||
end | ||
expect(page).to have_content(I18n.t('subject.new_verb')) | ||
end | ||
end | ||
|
||
context 'with a walk with a subject' do | ||
let!(:user) { FactoryBot.create(:user) } | ||
let!(:walk) { FactoryBot.create(:walk, | ||
user: user, | ||
courseline: [[12, 12], [12.1, 12]]) } | ||
let!(:stations) { FactoryBot.create_list(:station, 2, | ||
user: user, | ||
walk_id: walk.id, | ||
next: 1) } | ||
let!(:subject) { FactoryBot.create(:subject, user: user, | ||
station: stations.first) } | ||
|
||
scenario 'click on page link', js: true do | ||
sign_in user | ||
visit "/en/walks/#{walk.id}" | ||
expect(page).to have_content I18n.t('walk.publish.cannot') | ||
|
||
within '.walk-publish-container' do | ||
expect(page).to have_selector('.step-item:nth-of-type(4).active') | ||
expect(page).to have_selector('.step-item:nth-of-type(5) a:not([disabled])') | ||
click_link('Page') | ||
end | ||
expect(page).to have_content(I18n.t('page.new_verb')) | ||
end | ||
end | ||
|
||
context 'with a walk with a subject' do | ||
let!(:user) { FactoryBot.create(:user) } | ||
let!(:walk) { FactoryBot.create(:walk, | ||
user: user, | ||
courseline: [[12, 12], [12.1, 12]]) } | ||
let!(:stations) { FactoryBot.create_list(:station, 2, | ||
user: user, | ||
walk_id: walk.id, | ||
next: 1) } | ||
let!(:subject) { FactoryBot.create(:subject, user: user, | ||
station: stations.first) } | ||
|
||
scenario 'click on page link', js: true do | ||
sign_in user | ||
visit "/en/walks/#{walk.id}" | ||
expect(page).to have_content I18n.t('walk.publish.cannot') | ||
|
||
within '.walk-publish-container' do | ||
expect(page).to have_selector('.step-item:nth-of-type(4).active') | ||
expect(page).to have_selector('.step-item:nth-of-type(5) a:not([disabled])') | ||
click_link('Page') | ||
end | ||
expect(page).to have_content(I18n.t('page.new_verb')) | ||
end | ||
end | ||
|
||
pending 'with a publishable walk' do | ||
let!(:user) { FactoryBot.create(:user, username: 'foobi') } | ||
let!(:walk) { FactoryBot.create(:walk, | ||
user: user, | ||
courseline: [[12, 12], [12.1, 12]]) } | ||
let!(:stations) { FactoryBot.create_list(:station, 2, | ||
user: user, | ||
walk_id: walk.id, | ||
next: 1) } | ||
let!(:subject) { FactoryBot.create(:subject, user: user, | ||
station_id: stations.first.id) } | ||
let!(:page) { FactoryBot.create(:page, user: user, | ||
subject_id: subject.id) } | ||
|
||
scenario 'click on publish button', js: true do | ||
sign_in user | ||
visit "/en/walks/#{walk.id}" | ||
click_link 'Your walks' | ||
click_link walk.name | ||
expect(page).to have_content I18n.t('walk.publish.can') | ||
|
||
within '.walk-publish-container' do | ||
find('[data-tooltip="Publish walk"]').click | ||
end | ||
expect(page).to_not have_content I18n.t('walk.publish.can') | ||
expect(page).to_not have_selector '.walk-publish-container' | ||
expect(page).to have_selector '.walk-container span[data-tooltip="public"]' | ||
end | ||
end | ||
end |
Oops, something went wrong.