Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/organization.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var Organization = React.createClass({
);
},
teamSizeMatched: function() {
var sizeInput = this.props.sizeInput;
var sizeInput = this.props.techSizeSearch;
var techTeamSize = this.props.organization.tech_team_size;

return (
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/components/organization_display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ var OrganizationsDisplay = React.createClass({
<option value="3"> 50 or more </option>
</select>
<br />
<div class="container-fluid text-center">
<div className="container-fluid text-center">
<div class="row">
{ organizations }
{ console.log(organizations) }
</div>
</div>
<br />
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def new
def show
@claimed = @organization.claim_requests.find_by_status(true)
@news_articles = @organization.news_articles
hosting_event

respond_to do |format|
format.html { render }
Expand Down Expand Up @@ -95,9 +94,9 @@ def authorize_organization
redirect_to root_path unless can? :cru, @organization
end

def hosting_event
events = Event.all
def hosted_events
org_add = @organization.address.split(",")[0]
@find = events.where("location ILIKE ?", "%#{org_add}%")
@hosted_events ||= Event.hosted_at(org_add)
end
helper_method :hosted_events
end
7 changes: 7 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
class Event < ActiveRecord::Base

validates :meetup_url, uniqueness: true

def self.hosted_at(org_add)
where("location ILIKE ?", "%#{org_add}%")
end


end
2 changes: 1 addition & 1 deletion app/views/organizations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<div class="row sidebar-upcoming-events">
<div class="col-xs-12">
<h2>Upcoming Events</h2>
<% @find.each do |list| %>
<% hosted_events.each do |list| %>
<p>
<div class="event-name">
<%= link_to list.meetup_title, list.meetup_url %>
Expand Down
13 changes: 12 additions & 1 deletion spec/controllers/organizations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
end

describe "as common user" do
let (:published_organization) {FactoryGirl.create(:published_organization, address: "142 W Hastings St, Vancouver")}
let (:event) {FactoryGirl.create(:event, location: "142 W Hastings St, Vancouver")}

before { login(user) }
it "doesn't display unpublished organizations" do
expect { get :show, id: unpublished_organization.id }.to raise_exception(ActiveRecord::RecordNotFound)
Expand All @@ -65,6 +68,12 @@
get :show, id: published_organization.id
expect(assigns(:organization)).to eq(published_organization)
end

it "display meetup events hosted by published organization" do
event
get :show, id: published_organization.id
expect(subject.send(:hosted_events)).to include event
end
end

describe "as an admin" do
Expand All @@ -79,6 +88,8 @@
expect(assigns(:organization)).to eq(published_organization)
end
end


end

describe "#index" do
Expand All @@ -101,7 +112,7 @@
get :index
expect(assigns(:organizations)).to include(unpublished_organization)
end

it "does display published organizations on index" do
get :index
expect(assigns(:organizations)).to include(published_organization)
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
meetup_title "MyString"
meetup_url "MyString"
location "MyString"
time 1
start_time Time.now + 10.days
end
end