docbrown/spec/requests/root_page_spec.rb
Dwight Scott 1cb45995cb
conditionally render create post button for admins #16490 (#16606)
* Trigger Build

* WIP - use turbo to render html for create post button

todos and discussion topics
[] add tests (probably gonna be a lot of cypress 😅😭)
[] nominclature & file structure for authorization controller/routes
[] is this "authorizations" namespace approach the best?
[] authorization strategy relies on current user and caching doesn't
like `current_user`

* Use URL helper and not change the policy just yet

* put the turbo frame behind a feature flag

* Trigger Build

* Use URL helper and not change the policy just yet

* :)

* Add some test coverage and use same feature flag for consistency

* rubocop

* more rubocop

* trigger build

* adding a small sleep to see if specs pass 😩

* remove sleep

* disable Turbo session drive

* WIP

* Revert "WIP"

This reverts commit ce838672069fd703122156a0d82e5e6ad5398e0a.

* Moving spec from dashboard to root

With forem/forem#16913 the underlying test broke because we were
redirecting on the dashboard.

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
2022-03-29 13:04:57 -04:00

31 lines
780 B
Ruby

require "rails_helper"
RSpec.describe "Homepage", type: :request do
let(:user) { create(:user) }
describe "GET /" do
context "when limit post creation to admins" do
before { FeatureFlag.add("limit_post_creation_to_admins") }
after { FeatureFlag.remove("limit_post_creation_to_admins") }
it "does not render turbo frame when disabled" do
FeatureFlag.disable("limit_post_creation_to_admins")
sign_in user
get root_path
expect(response.body).not_to include("turbo-frame")
end
it "renders turbo frame when enabled" do
FeatureFlag.enable("limit_post_creation_to_admins")
sign_in user
get root_path
expect(response.body).to include("turbo-frame")
end
end
end
end