mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
FIX: correctly pass updateGroupings to the modal (#28683)
A previous refactor has moved this function in the controller instead of the route making it inaccessible to the modal. This commit is fixing this and also adding a spec.
This commit is contained in:
parent
997fbc9757
commit
b4f8ea6ade
|
@ -37,13 +37,17 @@
|
|||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
<DButton @action={{this.add}} @label="admin.badges.new" />
|
||||
<DButton
|
||||
@action={{this.add}}
|
||||
class="badge-groupings__add-grouping"
|
||||
@label="admin.badges.new"
|
||||
/>
|
||||
</:body>
|
||||
<:footer>
|
||||
<DButton
|
||||
@action={{this.saveAll}}
|
||||
@label="admin.badges.save"
|
||||
class="btn-primary"
|
||||
class="btn-primary badge-groupings__save"
|
||||
@disabled={{this.submitDisabled}}
|
||||
/>
|
||||
<DButton
|
||||
|
|
|
@ -29,6 +29,11 @@ export default class AdminBadgesRoute extends DiscourseRoute {
|
|||
});
|
||||
}
|
||||
|
||||
@action
|
||||
updateGroupings(groupings) {
|
||||
this.controllerFor("admin-badges").set("badgeGroupings", groupings);
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
const json = this._json;
|
||||
const badgeTriggers = [];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { action, get } from "@ember/object";
|
||||
import { get } from "@ember/object";
|
||||
import Route from "@ember/routing/route";
|
||||
import { service } from "@ember/service";
|
||||
import Badge from "discourse/models/badge";
|
||||
|
@ -28,9 +28,4 @@ export default class AdminBadgesShowRoute extends Route {
|
|||
|
||||
controller.setup();
|
||||
}
|
||||
|
||||
@action
|
||||
updateGroupings(groupings) {
|
||||
this.controllerFor("admin-badges").set("badgeGroupings", groupings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
@action={{route-action "editGroupings"}}
|
||||
@translatedLabel="Group settings"
|
||||
@icon="cog"
|
||||
@class="btn-default"
|
||||
@class="btn-default edit-groupings-btn"
|
||||
/>
|
||||
|
||||
<LinkTo @route="adminBadges.show" @model="new" class="btn btn-primary">
|
||||
|
|
21
spec/system/admin_badges_grouping_modal_spec.rb
Normal file
21
spec/system/admin_badges_grouping_modal_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe "Admin Badges Grouping Modal", type: :system do
|
||||
before { SiteSetting.enable_badges = true }
|
||||
|
||||
fab!(:current_user) { Fabricate(:admin) }
|
||||
|
||||
let(:badges_page) { PageObjects::Pages::AdminBadges.new }
|
||||
let(:badges_groupings_page) { PageObjects::Pages::AdminBadgesGroupings.new }
|
||||
|
||||
before { sign_in(current_user) }
|
||||
|
||||
context "when adding a new grouping" do
|
||||
it "saves it" do
|
||||
badges_page.visit_page(Badge::Autobiographer).edit_groupings
|
||||
badges_groupings_page.add_grouping("a new grouping")
|
||||
|
||||
try_until_success { BadgeGrouping.exists?(name: "a new grouping") }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -56,6 +56,11 @@ module PageObjects
|
|||
self
|
||||
end
|
||||
|
||||
def edit_groupings
|
||||
page.find(".edit-groupings-btn").click
|
||||
self
|
||||
end
|
||||
|
||||
def form
|
||||
@form ||= PageObjects::Components::FormKit.new("form")
|
||||
end
|
||||
|
|
32
spec/system/page_objects/admin_badges_groupings.rb
Normal file
32
spec/system/page_objects/admin_badges_groupings.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Pages
|
||||
class AdminBadgesGroupings < PageObjects::Pages::Base
|
||||
def add_grouping(name)
|
||||
within(modal) do
|
||||
find(".badge-groupings__add-grouping").click
|
||||
find(".badge-grouping-name-input").fill_in(with: name)
|
||||
end
|
||||
|
||||
save
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
def save
|
||||
page.find(".badge-groupings__save").click
|
||||
expect(self).to be_closed
|
||||
self
|
||||
end
|
||||
|
||||
def modal
|
||||
page.find(".badge-groupings-modal")
|
||||
end
|
||||
|
||||
def closed?
|
||||
page.has_no_css?(".badge-groupings-modal")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user