Skip to content

Commit

Permalink
Move group issues list into their own controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
Odaeus committed Mar 2, 2012
1 parent 52be70a commit 09a0c7e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 11 deletions.
18 changes: 18 additions & 0 deletions app/controllers/group/issues_controller.rb
@@ -0,0 +1,18 @@
# Note inheritance
class Group::IssuesController < IssuesController
filter_access_to :all, context: :issues

def index
set_page_title t(".title", group_name: current_group.name)

# FIXME: bad design, @query is set by search action
if @query
issues = Issue.intersects(current_group.profile.location).find_with_index(@query)
else
issues = Issue.intersects(current_group.profile.location).by_most_recent.paginate(page: params[:page])
end

@issues = IssueDecorator.decorate(issues)
@start_location = index_start_location
end
end
1 change: 1 addition & 0 deletions app/controllers/group/message_threads_controller.rb
@@ -1,3 +1,4 @@
# Note inheritance
class Group::MessageThreadsController < MessageThreadsController
before_filter :load_group

Expand Down
15 changes: 4 additions & 11 deletions app/controllers/issues_controller.rb
Expand Up @@ -2,20 +2,13 @@ class IssuesController < ApplicationController
filter_access_to [:edit, :update, :destroy], attribute_check: true

def index
if current_group
if @query
issues = Issue.intersects(current_group.profile.location).find_with_index(@query)
else
issues = Issue.intersects(current_group.profile.location).by_most_recent.paginate(page: params[:page])
end
# FIXME: this is confusing design, the query param is set by the search action
if @query
issues = Issue.find_with_index(@query)
else
issues = Issue.by_most_recent.paginate(page: params[:page])
if @query
issues = Issue.find_with_index(@query)
else
issues = Issue.by_most_recent.paginate(page: params[:page])
end
end

@issues = IssueDecorator.decorate(issues)
@start_location = index_start_location
end
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en-GB.yml
Expand Up @@ -90,6 +90,9 @@
title: "Sign in"
sign_in_button: "Sign in"
group:
issues:
index:
title: "Issues in the area of %{group_name}"
members:
index:
actions: "Actions"
Expand Down
33 changes: 33 additions & 0 deletions spec/requests/groups/issues_spec.rb
@@ -0,0 +1,33 @@
require "spec_helper"

describe "Issues in a group subdomain" do
include_context "signed in as a group member"
include_context "with current group subdomain"

let!(:group_profile) { FactoryGirl.create(:big_group_profile, group: current_group) }

context "index" do
let(:location_inside_group) { "POINT (10 10)" }
let(:location_outside_group) { "POINT (200 200)" }
let!(:issues) { FactoryGirl.create_list(:issue, 2, location: location_inside_group) }
let(:outside_issue) { FactoryGirl.create(:issue, location: location_outside_group) }

it "should show issues in the group's area" do
visit issues_path
issues.each do |issue|
page.should have_content(issue.title)
end
end

it "should not show issues outside the group's area" do
outside_issue
visit issues_path
page.should have_no_content(outside_issue.title)
end

it "should set the page title" do
visit issues_path
page.should have_selector("title", content: I18n.t("group.issues.index.title", group_name: current_group.name))
end
end
end

0 comments on commit 09a0c7e

Please sign in to comment.