Skip to content

Commit 2085dd9

Browse files
committed
Try some dubious fixes
1 parent 9ba6277 commit 2085dd9

File tree

5 files changed

+39
-19
lines changed

5 files changed

+39
-19
lines changed

core/app/assets/stylesheets/refinery/sections/_layout.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ label.stripped {
895895
padding-top: 4px;
896896
}
897897

898-
#records.tree li span.item {
898+
#records.tree li span.icon {
899899
display: block;
900900
float: left;
901901
width: 16px;

pages/app/controllers/refinery/admin/page_parts_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Refinery
22
module Admin
33
class PagePartsController < ::Refinery::AdminController
4+
skip_after_action :store_location?, raise: false
45

56
def new
67
render :partial => '/refinery/admin/pages/page_part_field', :locals => {

pages/app/helpers/refinery/admin/pages_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def page_icon(number_of_children)
6060
# 2. no_children 'page'
6161

6262
# .toggle scss handles adding icons to pages with children
63-
classes = []
63+
classes = ['icon']
6464
case
6565
when number_of_children.zero?
6666
classes.push icon_class('page')
6767
title = ::I18n.t('edit', scope: 'refinery.admin.pages')
6868
else
6969
expanded_class = Refinery::Pages.auto_expand_admin_tree ? 'expanded' : ''
70-
classes.push ['toggle', expanded_class]
70+
classes.push 'toggle', expanded_class
7171
title = ::I18n.t('expand_collapse', scope: 'refinery.admin.pages')
7272
end
7373

pages/app/views/refinery/admin/pages/_form.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<%= render 'form_fields_after_title', f: f %>
1414

15-
<div class='field'>
15+
<div class="field">
1616
<%= render 'form_page_parts', f: f %>
1717
</div>
1818

@@ -64,7 +64,7 @@
6464
action: prev_url,
6565
target: prev_target
6666
});
67-
}, 100);
67+
}, 500);
6868
});
6969
});
7070
</script>

pages/spec/system/refinery/admin/pages_spec.rb

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def switch_page_form_locale(locale)
1919
end
2020

2121
# make sure that the locale change has taken effect
22-
expect(page).to have_selector("#switch_locale_picker li.selected a##{locale.downcase}")
22+
expect(page).to have_selector("#switch_locale_picker a.selected##{locale.downcase}")
2323
end
2424

2525
module Refinery
@@ -93,9 +93,14 @@ module Admin
9393
let!(:location) { locations.children.create title: 'New York' }
9494

9595
context "with auto expand option turned off" do
96-
before do
97-
allow(Refinery::Pages).to receive(:auto_expand_admin_tree).and_return(false)
96+
around do |example|
97+
old_value = Refinery::Pages.auto_expand_admin_tree
98+
Refinery::Pages.auto_expand_admin_tree = false
99+
example.run
100+
Refinery::Pages.auto_expand_admin_tree = old_value
101+
end
98102

103+
before do
99104
visit refinery.admin_pages_path
100105
end
101106

@@ -110,25 +115,30 @@ module Admin
110115
end
111116

112117
it "expands children", js: true do
113-
find("#page_#{company.id} .item .toggle").click
118+
find("#page_#{company.id} .icon.toggle").click
114119

115120
expect(page).to have_content(team.title)
116121
expect(page).to have_content(locations.title)
117122
end
118123

119124
it "expands children when nested multiple levels deep", js: true do
120-
find("#page_#{company.id} .item .toggle").click
121-
find("#page_#{locations.id} .item .toggle").click
125+
find("#page_#{company.id} .icon.toggle").click
126+
find("#page_#{locations.id} .icon.toggle").click
122127

123128
expect(page).to have_content("New York")
124129
end
125130
end
126131

127132
context "with auto expand option turned on" do
128-
before do
129-
allow(Refinery::Pages).to receive(:auto_expand_admin_tree).and_return(true)
133+
around do |example|
134+
old_value = Refinery::Pages.auto_expand_admin_tree
135+
Refinery::Pages.auto_expand_admin_tree = true
130136
Rails.cache.clear
137+
example.run
138+
Refinery::Pages.auto_expand_admin_tree = old_value
139+
end
131140

141+
before do
132142
visit refinery.admin_pages_path
133143
end
134144

@@ -359,6 +369,9 @@ module Admin
359369

360370
window.close
361371

372+
# Wait for setTimeout to restore form action/target after preview
373+
sleep 0.6
374+
362375
click_button "Save & continue editing"
363376
expect(page).to have_content("'Save this' was successfully updated")
364377
end
@@ -459,9 +472,14 @@ module Admin
459472
end
460473

461474
context "with translations" do
462-
before do
463-
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
475+
around do |example|
476+
old_locales = Refinery::I18n.config.frontend_locales
477+
Refinery::I18n.config.frontend_locales = [:en, :ru]
478+
example.run
479+
Refinery::I18n.config.frontend_locales = old_locales
480+
end
464481

482+
before do
465483
# Create a home page in both locales (needed to test menus)
466484
home_page = Mobility.with_locale(:en) do
467485
Page.create title: 'Home',
@@ -529,8 +547,6 @@ module Admin
529547
let(:ru_page_title) { 'Новости' }
530548
let(:ru_page_slug_encoded) { '%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8' }
531549
let!(:news_page) do
532-
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
533-
534550
_page = Mobility.with_locale(:en) {
535551
Page.create title: en_page_title
536552
}
@@ -698,8 +714,11 @@ module Admin
698714
end
699715

700716
describe "new page part" do
701-
before do
702-
allow(Refinery::Pages).to receive(:new_page_parts).and_return(true)
717+
around do |example|
718+
old_value = Refinery::Pages.new_page_parts
719+
Refinery::Pages.new_page_parts = true
720+
example.run
721+
Refinery::Pages.new_page_parts = old_value
703722
end
704723

705724
it "adds new page part", js: true do

0 commit comments

Comments
 (0)