Merge remote-tracking branch 'origin/routes-tidy-up' into routes-tidy-up

This commit is contained in:
Brenda Wallace
2019-01-24 13:47:17 +13:00
8 changed files with 15 additions and 14 deletions

View File

@@ -87,6 +87,7 @@ submit the change with your pull request.
- Christopher Bazin / [RobotScissors](https://github.com/robotscissors)
- Ahmed Shahin / [codeminator](https://www.github.com/codeminator)
- Brandon Baker / [brandonbaker40](https://github.com/brandonbaker40)
- Alex Darr / [apdarr](https://github.com/apdarr)
## Bots

View File

@@ -17,7 +17,7 @@ function showCropMap(cropmap) {
var marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude));
var planting_url = "/plantings/" + planting.id;
var planting_link = "<a href='" + planting_url + "'>" + owner.slug + "'s " + crop.name + "</a>";
var planting_link = "<a href='" + planting_url + "'>" + owner.login_name + "'s " + crop.name + "</a>";
var where = "<p><i>" + owner.location + "</i></p>";
@@ -54,4 +54,4 @@ $(document).ready(function() {
$('.btn.toggle.crop-hierarchy').click(function () {
$('.toggle.crop-hierarchy').toggleClass('hide');
});
});
});

View File

@@ -18,7 +18,7 @@ if (document.getElementById("membermap") !== null) {
var marker = new L.Marker(new L.LatLng(member.latitude, member.longitude));
var member_url = "/members/" + member.slug;
var member_link = "<a href='" + member_url + "'>" + member.slug + "</a>";
var member_link = "<a href='" + member_url + "'>" + member.login_name + "</a>";
var where = "<p><i>" + member.location + "</i></p>";

View File

@@ -11,7 +11,7 @@ module Charts
end
def harvested_for
@crop = Crop.find(params[:crop_slug])
@crop = Crop.find_by!(slug: params[:crop_slug])
render json: Harvest.joins(:plant_part)
.where(crop: @crop)
.group("plant_parts.name").count(:id)
@@ -20,7 +20,7 @@ module Charts
private
def pie_chart_query(field)
@crop = Crop.find(params[:crop_slug])
@crop = Crop.find_by!(slug: params[:crop_slug])
render json: Planting.where(crop: @crop)
.where.not(field.to_sym => nil)
.where.not(field.to_sym => '')

View File

@@ -49,7 +49,7 @@ class CropsController < ApplicationController
end
def show
@crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:slug])
@crop = Crop.includes(:scientific_names, plantings: :photos).find_by!(slug: params[:slug])
@posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page])
# respond_with(@crop)
respond_to do |format|
@@ -67,7 +67,7 @@ class CropsController < ApplicationController
end
def edit
@crop = Crop.find_by(slug: params[:slug])
@crop = Crop.find_by!(slug: params[:slug])
@crop.alternate_names.build if @crop.alternate_names.blank?
@crop.scientific_names.build if @crop.scientific_names.blank?
end
@@ -88,7 +88,7 @@ class CropsController < ApplicationController
end
def update
@crop = Crop.find_by(slug: params[:slug])
@crop = Crop.find_by!(slug: params[:slug])
previous_status = @crop.approval_status
@crop.creator = current_member if previous_status == "pending"

View File

@@ -8,8 +8,8 @@ class SeedsController < ApplicationController
# GET /seeds
# GET /seeds.json
def index
@owner = Member.find_by(slug: params[:member_slug])
@crop = Crop.find_by(slug: params[:crop_slug])
@owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug].present?
@crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug].present?
@seeds = @seeds.where(owner: @owner) if @owner.present?
@seeds = @seeds.where(crop: @crop) if @crop.present?

View File

@@ -65,7 +65,7 @@ common: &default_settings
# encryption involved in SSL communication, but this work is done
# asynchronously to the threads that process your application code,
# so it should not impact response times.
ssl: false
ssl: true
# EXPERIMENTAL: enable verification of the SSL certificate sent by
# the server. This setting has no effect unless SSL is enabled

View File

@@ -33,17 +33,17 @@ describe Notification do
it "sends email if asked" do
@notification2 = FactoryBot.create(:notification)
@notification2.send_email
expect(ActionMailer::Base.deliveries.last.to).to eq [@notification2.recipient.email]
expect(ActionMailer::Base.deliveries.last&.to).to eq [@notification2.recipient.email]
end
it "doesn't send email to people who don't want it" do
FactoryBot.create(:no_email_notification).send_email
expect(ActionMailer::Base.deliveries.last.to).not_to eq [notification.recipient.email]
expect(ActionMailer::Base.deliveries.last&.to).not_to eq [notification.recipient.email]
end
it "sends email on creation" do
@notification2 = FactoryBot.create(:notification)
expect(ActionMailer::Base.deliveries.last.to).to eq [@notification2.recipient.email]
expect(ActionMailer::Base.deliveries.last&.to).to eq [@notification2.recipient.email]
end
it "replaces missing subjects with (no subject)" do