Skip to content
Merged
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
3 changes: 2 additions & 1 deletion admins/pageflow/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@
text_attribute: :name,
scope: lambda do
AccountPolicy::Scope
.new(current_user, Account)

Check warning on line 104 in admins/pageflow/entry.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/MultilineMethodCallIndentation: Align `.new` with `AccountPolicy::Scope` on line 103.
.entry_movable

Check warning on line 105 in admins/pageflow/entry.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/MultilineMethodCallIndentation: Align `.entry_movable` with `AccountPolicy::Scope` on line 103.
.order(:name)

Check warning on line 106 in admins/pageflow/entry.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/MultilineMethodCallIndentation: Align `.order` with `AccountPolicy::Scope` on line 103.
end)

searchable_select_options(name: :eligible_sites,
Expand All @@ -111,8 +111,8 @@
scope: lambda do |params|
account = Account.find(params[:account_id])
SitePolicy::Scope
.new(current_user, Site)

Check warning on line 114 in admins/pageflow/entry.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/MultilineMethodCallIndentation: Align `.new` with `SitePolicy::Scope` on line 113.
.sites_allowed_for(account)

Check warning on line 115 in admins/pageflow/entry.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/MultilineMethodCallIndentation: Align `.sites_allowed_for` with `SitePolicy::Scope` on line 113.
end,
filter: lambda do |term, scope|
scope.ransack(account_name_cont: term).result
Expand Down Expand Up @@ -330,7 +330,8 @@
result += Pageflow.config_for(target).admin_form_inputs.permitted_attributes_for(:entry)
result += permitted_account_attributes

result << :folder_id if params[:id] && authorized?(:configure_folder_for, resource)
result << :folder_id if create_or_new_action? ||
(params[:id] && authorized?(:configure_folder_for, resource))

accounts = if params[:id]
resource.account
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ de:
account: Konto
author: Autor
created_at: Erstellt
folder: Ordner
credits: Credits
structured_data_type_name: Strukturierter Datentyp
edited_at: Geändert
Expand Down
24 changes: 24 additions & 0 deletions spec/controllers/admin/entries_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,30 @@ def self.name
expect(request).to redirect_to(admin_entry_path(Pageflow::Entry.last))
end

it 'allows account publisher to create entry in folder' do
user = create(:user)
account = create(:account, with_publisher: user)
folder = create(:folder, account:)

sign_in(user, scope: :user)

post :create, params: {entry: attributes_for(:entry, account:, folder_id: folder)}

expect(Pageflow::Entry.last.folder).to eq(folder)
end

it 'does not allow account publisher to create entry in folder of other account' do
user = create(:user)
account = create(:account, with_publisher: user)
folder = create(:folder, account: create(:account))

sign_in(user, scope: :user)

expect {
post :create, params: {entry: attributes_for(:entry, account:, folder_id: folder)}
}.not_to change(Pageflow::Entry, :count)
end

it 'redirects to editor if after_entry_create is set to editor' do
user = create(:user)
account = create(:account, with_publisher: user)
Expand Down
Loading