Skip to content

Commit

Permalink
Backport Fix issue editing and deleting a specific post (#3360)
Browse files Browse the repository at this point in the history
* add id when search post and specs

* add changelog line.

* add validation on area to prevent the failing test
  • Loading branch information
isaacmg410 authored and mrcasals committed May 10, 2018
1 parent ba4a679 commit c69bf0f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

**Fixed**:

- **decidim-blog**: Add `params[:id]` when editing/deleting a post from admin site [\#3360](https://github.com/decidim/decidim/pull/3360)
- **decidim-admin**: Fixes the validation uniqueness name of area, scoped with organization and area_type [\#3350](https://github.com/decidim/decidim/pull/3350)

## [0.11.0.pre](https://github.com/decidim/decidim/tree/v0.11.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def destroy
private

def post
@post ||= Blogs::Post.find_by(component: current_component)
@post ||= Blogs::Post.find_by(component: current_component, id: params[:id])
end
end
end
Expand Down
18 changes: 7 additions & 11 deletions decidim-blogs/spec/shared/manage_posts_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

shared_examples "manage posts" do
it "updates a post" do
within find("tr", text: translated(post.title)) do
within find("tr", text: translated(post1.title)) do
click_link "Edit"
end

Expand All @@ -29,6 +29,7 @@

within "table" do
expect(page).to have_content("My new title")
expect(page).to have_content("Post title 2")
end
end

Expand Down Expand Up @@ -59,31 +60,26 @@

within "table" do
expect(page).to have_content("My post")
expect(page).to have_content("Post title 1")
expect(page).to have_content("Post title 2")
end
end

describe "deleting a post" do
let(:title) do
{
en: "This is the title of deleted post",
es: "Este es el título del post eliminado",
ca: "Aquest és el títol del post eliminat"
}
end

before do
visit current_path
end

it "deletes a post" do
within find("tr", text: translated(post.title)) do
within find("tr", text: translated(post1.title)) do
accept_confirm { click_link "Delete" }
end

expect(page).to have_admin_callout("successfully")

within "table" do
expect(page).to have_no_content(translated(post.title))
expect(page).to have_no_content(translated(post1.title))
expect(page).to have_content(translated(post2.title))
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion decidim-blogs/spec/system/admin_manages_posts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

describe "Admin manages posts", type: :system do
let(:manifest_name) { "blogs" }
let!(:post) { create :post, component: current_component }
let!(:post1) { create :post, component: current_component, title: { en: "Post title 1" } }
let!(:post2) { create :post, component: current_component, title: { en: "Post title 2" } }

include_context "when managing a component as an admin"

Expand Down
3 changes: 2 additions & 1 deletion decidim-blogs/spec/system/process_admin_manages_post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

describe "Process admin manages post", type: :system do
let(:manifest_name) { "blogs" }
let!(:post) { create :post, component: current_component }
let!(:post1) { create :post, component: current_component, title: { en: "Post title 1" } }
let!(:post2) { create :post, component: current_component, title: { en: "Post title 2" } }

include_context "when managing a component as a process admin"

Expand Down

0 comments on commit c69bf0f

Please sign in to comment.