Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Restrict plugin to specific groups.
- Loading branch information
Showing
8 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
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
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,55 @@ | ||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers"; | ||
|
||
// TODO: Figure out why `await` is not enough. | ||
function sleep(time) { | ||
return new Promise(resolve => { | ||
setTimeout(() => resolve(), time); | ||
}); | ||
} | ||
|
||
acceptance("Encrypt - Settings", { | ||
loggedIn: true, | ||
settings: { encrypt_enabled: true, encrypt_groups: "" } | ||
}); | ||
|
||
test("encrypt settings visible only to allowed groups", async assert => { | ||
await visit("/u/eviltrout/preferences"); | ||
await sleep(1500); | ||
|
||
assert.ok(find(".encrypt").text().length > 0, "encrypt settings are visible"); | ||
|
||
Discourse.SiteSettings.encrypt_groups = "allowed_group"; | ||
|
||
replaceCurrentUser({ | ||
groups: [ | ||
Ember.Object.create({ | ||
id: 1, | ||
name: "not_allowed_group" | ||
}) | ||
] | ||
}); | ||
|
||
await visit("/u/eviltrout/preferences"); | ||
await sleep(1500); | ||
assert.ok( | ||
find(".encrypt").text().length === 0, | ||
"encrypt settings are not visible" | ||
); | ||
|
||
replaceCurrentUser({ | ||
groups: [ | ||
Ember.Object.create({ | ||
id: 1, | ||
name: "not_allowed_group" | ||
}), | ||
Ember.Object.create({ | ||
id: 2, | ||
name: "allowed_group" | ||
}) | ||
] | ||
}); | ||
|
||
await visit("/u/eviltrout/preferences"); | ||
await sleep(1500); | ||
assert.ok(find(".encrypt").text().length > 0, "encrypt settings are visible"); | ||
}); |
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