Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chapter_16' into chapter_17
* chapter_16: Mount forem engine within this application Update schema for delayed job Ticket notifications are now a background job Implement tidier caching for the tickets list on the projects page Add ETag and Last-Modified support to ticket show page Add fragment caching to ticket listings on a project Added pagination for tickets Conflicts: config/routes.rb
- Loading branch information
Showing
25 changed files
with
223 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CommentNotifierJob < Struct.new(:comment_id) | ||
def perform | ||
comment = Comment.find(comment_id) | ||
watchers = comment.ticket.watchers - [comment.user] | ||
watchers.each do |user| | ||
Notifier.comment_updated(comment, user).deliver | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class TicketsSweeper < ActionController::Caching::Sweeper | ||
observe Ticket | ||
def after_create(ticket) | ||
expire_fragments_for_project(ticket.project) | ||
end | ||
|
||
def after_update(ticket) | ||
expire_fragments_for_project(ticket.project) | ||
end | ||
|
||
def after_destroy(ticket) | ||
expire_fragments_for_project(ticket.project) | ||
end | ||
|
||
private | ||
|
||
def expire_fragments_for_project(project) | ||
expire_fragment(/projects\/#{project.id}\/.*?/) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env ruby | ||
# | ||
# This file was generated by Bundler. | ||
# | ||
# The application 'rdiscount' is installed as part of a gem, and | ||
# this file is here to facilitate running it. | ||
# | ||
|
||
require 'pathname' | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", | ||
Pathname.new(__FILE__).realpath) | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
|
||
load Gem.bin_path('rdiscount', 'rdiscount') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Forem::Engine.user_class = User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddProjectIdIndexToTickets < ActiveRecord::Migration | ||
def change | ||
add_index :tickets, :project_id | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateForemTopics < ActiveRecord::Migration | ||
def change | ||
create_table :forem_topics do |t| | ||
t.text :subject | ||
t.integer :user_id | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateForemPosts < ActiveRecord::Migration | ||
def change | ||
create_table :forem_posts do |t| | ||
t.integer :topic_id | ||
t.text :text | ||
t.integer :user_id | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddPostsCountToForemTopics < ActiveRecord::Migration | ||
def change | ||
add_column :forem_topics, :posts_count, :integer, :default => 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Feature: Paginating tickets | ||
In order to ease the load on the server | ||
As the system | ||
I want paginate ticket results | ||
|
||
Background: | ||
Given there is a project called "Internet Explorer" | ||
Given there are the following users: | ||
| email | password | | ||
| user@ticketee.com | password | | ||
And "user@ticketee.com" can view the "Internet Explorer" project | ||
And I am signed in as them | ||
And there are 100 tickets for this project | ||
|
||
When I am on the homepage | ||
And I follow "Internet Explorer" | ||
|
||
Scenario: Viewing the second page | ||
Then I should see 2 pages of pagination | ||
When I follow "Next" within ".pagination .next" | ||
Then I see page 2 of tickets for this project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Then /^I should see (\d+) pages of pagination$/ do |number| | ||
pages = all(".pagination .page") | ||
pages.count.should eql(number.to_i) | ||
end | ||
|
||
Then /^I see page (\d+) of tickets for this project$/ do |number| | ||
current_page = find(".pagination .current").text.strip | ||
current_page.should eql(number) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.