-
-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathlanguage_tree_feature_spec.rb
64 lines (51 loc) · 2 KB
/
language_tree_feature_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true
require "rails_helper"
RSpec.describe "Language tree feature", type: :system, js: true do
let(:klingon) { create(:alchemy_language, :klingon) }
let(:user) { build(:alchemy_dummy_user, :as_admin) }
before do
create(:alchemy_page, :language_root)
authorize_user(user)
end
context "with a single language" do
it "one should not be able to switch the language tree" do
visit("/admin/pages")
expect(page).to_not have_selector("label", text: Alchemy.t("Language tree"))
end
end
context "in a multilangual environment" do
context "even if one language is not public" do
let(:klingon) { create(:alchemy_language, :klingon, public: false) }
before do
create(:alchemy_page, :language_root, name: "Klingon", language: klingon)
end
context "and an author" do
let(:user) { build(:alchemy_dummy_user, :as_author) }
it "one should not be able to switch the language tree" do
visit("/admin/pages")
expect(page).to_not have_selector("label", text: Alchemy.t("Language tree"))
end
end
context "and an editor" do
let(:user) { build(:alchemy_dummy_user, :as_editor) }
it "one should be able to switch the language tree" do
visit("/admin/pages")
expect(page).to have_link_with_tooltip(Alchemy.t("Language tree"))
end
end
end
end
context "with no language root page" do
before { klingon }
it "displays a form for creating language root with preselected page layout and front page name" do
visit("/admin/pages")
select2 "Klingon", from: "Language tree"
expect(page).to have_content("This language has no homepage yet")
within("form#create_language_tree") do
expect(page).to \
have_selector('input[type="text"][value="' + klingon.frontpage_name + '"]')
expect(page).to have_selector('option[selected="selected"][value="' + klingon.page_layout + '"]')
end
end
end
end