Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/policies/story_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ def index?
true
end

def share_portal?
true
end

def show?
admin? || record.publicly_visible? || (authenticated? && record.published?)
end

def show_share_portal?
show?
end

# Scoping
# See https://actionpolicy.evilmartians.io/#/scoping
#
Expand Down
41 changes: 41 additions & 0 deletions spec/requests/stories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
end
end

describe "GET /show_share_portal" do
it "can view any story in share portal" do
get show_share_portal_story_url(private_story)
expect(response).to have_http_status(:ok)
end
end

describe "POST /create" do
it "creates a story" do
expect {
Expand Down Expand Up @@ -100,6 +107,23 @@
end
end

describe "GET /show_share_portal" do
it "can view published story in share portal" do
get show_share_portal_story_url(published_story)
expect(response).to have_http_status(:ok)
end

it "can view publicly visible story in share portal" do
get show_share_portal_story_url(public_story)
expect(response).to have_http_status(:ok)
end

it "cannot view private story in share portal" do
get show_share_portal_story_url(private_story)
expect(response).to redirect_to(root_path)
end
end

describe "POST /create" do
it "is unauthorized" do
post stories_url, params: { story: base_attributes }
Expand Down Expand Up @@ -134,6 +158,23 @@
end
end

describe "GET /show_share_portal" do
it "can view publicly visible story in share portal" do
get show_share_portal_story_url(public_story)
expect(response).to have_http_status(:ok)
end

it "cannot view published-only story in share portal" do
get show_share_portal_story_url(published_story)
expect(response).to redirect_to(root_path)
end

it "cannot view private story in share portal" do
get show_share_portal_story_url(private_story)
expect(response).to redirect_to(root_path)
end
end

describe "POST /create" do
it "redirects to root" do
post stories_url, params: { story: base_attributes }
Expand Down
Loading