Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tag oriented feeds #213 #226

Merged
merged 2 commits into from
Aug 12, 2015
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
4 changes: 4 additions & 0 deletions app/controllers/monologue/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ def show

def feed
@posts = Monologue::Post.published.limit(25)
if params[:tags].present?
tags = Monologue::Tag.where(name: params[:tags].split(",")).pluck(:id)
@posts = @posts.joins(:taggings).where("monologue_taggings.tag_id in (?)", tags)
end
end
end
25 changes: 24 additions & 1 deletion spec/requests/feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,33 @@
before(:each) do
Factory(:post, url: "url/to/post")
end

# test to prevent regression for issue #72
it "should contain full" do
visit feed_path
page.should have_content "/monologue/url/to/post"
end

context "with tags param" do
before do
create(:post, title: "Feed Post").tag!(["feed"])
create(:post, title: "Rss Post").tag!(["rss"])
end

context "with tags" do
it "returns posts tagged with tags" do
visit feed_path(tags: "feed,rss")
page.should have_content "Feed Post"
page.should have_content "Rss Post"
end
end

context "without tags" do
it "returns all posts" do
visit feed_path(tags: "")
page.should have_content "Feed Post"
page.should have_content "Rss Post"
end
end
end
end