2019-07-03 16:14:28 +00:00
|
|
|
RSpec.shared_examples 'group-dependent text modules' do |path:|
|
|
|
|
|
|
|
|
let!(:group1) { create :group }
|
|
|
|
let!(:group2) { create :group }
|
|
|
|
let!(:text_module_without_group) { create :text_module }
|
|
|
|
let!(:text_module_group1) { create :text_module, groups: [group1] }
|
|
|
|
let!(:text_module_group2) { create :text_module, groups: [group2] }
|
|
|
|
|
|
|
|
it 'supports group-dependent text modules' do
|
|
|
|
|
|
|
|
# give user access to all groups including those created
|
|
|
|
# by using FactoryBot outside of the example
|
|
|
|
group_names_access_map = Group.all.pluck(:name).each_with_object({}) do |group_name, result|
|
|
|
|
result[group_name] = 'full'.freeze
|
|
|
|
end
|
|
|
|
|
|
|
|
current_user do |user|
|
|
|
|
user.group_names_access_map = group_names_access_map
|
|
|
|
user.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
visit path
|
|
|
|
|
|
|
|
within(:active_content) do
|
2019-08-07 12:55:54 +00:00
|
|
|
find('select[name="group_id"]').select(group1.name)
|
2019-07-03 16:14:28 +00:00
|
|
|
find(:richtext).send_keys('::')
|
|
|
|
|
2019-08-07 12:55:54 +00:00
|
|
|
expect(page).to have_selector(:text_module, text_module_without_group.id)
|
|
|
|
expect(page).to have_selector(:text_module, text_module_group1.id)
|
|
|
|
expect(page).to have_no_selector(:text_module, text_module_group2.id)
|
2019-07-03 16:14:28 +00:00
|
|
|
|
2019-08-07 12:55:54 +00:00
|
|
|
find('select[name="group_id"]').select(group2.name)
|
2019-07-03 16:14:28 +00:00
|
|
|
find(:richtext).send_keys('::')
|
|
|
|
|
2019-08-07 12:55:54 +00:00
|
|
|
expect(page).to have_selector(:text_module, text_module_without_group.id)
|
|
|
|
expect(page).to have_no_selector(:text_module, text_module_group1.id)
|
|
|
|
expect(page).to have_selector(:text_module, text_module_group2.id)
|
2019-07-03 16:14:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|