Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed macro event for TicketCreateFormHandler. This is not needed, …
…because there are no macros when creating tickets.
- Loading branch information
1 parent
7e2f55d
commit feac4bb
Showing
13 changed files
with
284 additions
and
53 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
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
11 changes: 11 additions & 0 deletions
11
app/assets/javascripts/app/controllers/ticket_zoom/form_handler_macro.coffee
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,11 @@ | ||
class TicketZoomFormHandlerMacro | ||
|
||
# central method, is getting called on every ticket form change | ||
# but only trigger event for group_id changes | ||
@run: (params, attribute, attributes, classname, form, ui) -> | ||
|
||
return if attribute.name isnt 'group_id' | ||
|
||
App.Event.trigger('MacroPreconditionUpdate', { taskKey: ui.taskKey, params: params }) | ||
|
||
App.Config.set('120-ticketFormMacro', TicketZoomFormHandlerMacro, 'TicketZoomFormHandler') |
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,18 @@ | ||
class GroupDependentMacros < ActiveRecord::Migration[4.2] | ||
def up | ||
|
||
create_table :groups_macros, id: false do |t| # rubocop:disable Rails/CreateTableWithTimestamps | ||
t.references :macro, null: false | ||
t.references :group, null: false | ||
end | ||
add_index :groups_macros, [:macro_id] | ||
add_index :groups_macros, [:group_id] | ||
add_foreign_key :groups_macros, :macros | ||
add_foreign_key :groups_macros, :groups | ||
|
||
end | ||
|
||
def self.down | ||
drop_table :groups_macros | ||
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
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,45 @@ | ||
RSpec.shared_examples 'macros' do |path:| | ||
|
||
let!(:group1) { create :group } | ||
let!(:group2) { create :group } | ||
let!(:macro_without_group) { create :macro } | ||
let!(:macro_group1) { create :macro, groups: [group1] } | ||
let!(:macro_group2) { create :macro, groups: [group2] } | ||
|
||
it 'supports group-dependent macros' 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 | ||
|
||
# refresh browser to get macro accessable | ||
refresh | ||
visit path | ||
|
||
within(:active_content) do | ||
|
||
# select group | ||
find('select[name="group_id"]').select(group1.name) | ||
|
||
open_macro_list | ||
expect(page).to have_selector(:macro, macro_without_group.id) | ||
expect(page).to have_selector(:macro, macro_group1.id) | ||
expect(page).to have_no_selector(:macro, macro_group2.id) | ||
|
||
# select group | ||
find('select[name="group_id"]').select(group2.name) | ||
|
||
open_macro_list | ||
expect(page).to have_selector(:macro, macro_without_group.id) | ||
expect(page).to have_no_selector(:macro, macro_group1.id) | ||
expect(page).to have_selector(:macro, macro_group2.id) | ||
end | ||
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
Oops, something went wrong.
feac4bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message hick-up... This actually fixes #1066.