mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-02 21:51:01 -05:00
Merge pull request #1061 from Br3nda/bw/long-lines-fixed
Wrapped all lines > 120 chars.
This commit is contained in:
10
.rubocop.yml
10
.rubocop.yml
@@ -8,6 +8,11 @@ AllCops:
|
||||
- 'db/schema.rb'
|
||||
- 'vendor/**/*'
|
||||
|
||||
Style/FileName:
|
||||
Exclude:
|
||||
- 'Gemfile'
|
||||
- 'Gemfile.lock'
|
||||
|
||||
Style/StringLiterals:
|
||||
Enabled: false
|
||||
|
||||
@@ -37,11 +42,8 @@ Metrics/ClassLength:
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 11
|
||||
|
||||
# Offense count: 1108
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
|
||||
# URISchemes: http, https
|
||||
Metrics/LineLength:
|
||||
Max: 223
|
||||
Max: 120
|
||||
|
||||
# Offense count: 8
|
||||
Metrics/PerceivedComplexity:
|
||||
|
||||
@@ -215,6 +215,15 @@ class CropsController < ApplicationController
|
||||
private
|
||||
|
||||
def crop_params
|
||||
params.require(:crop).permit(:en_wikipedia_url, :name, :parent_id, :creator_id, :approval_status, :request_notes, :reason_for_rejection, :rejection_notes, scientific_names_attributes: [:scientific_name, :_destroy, :id])
|
||||
params.require(:crop).permit(:en_wikipedia_url,
|
||||
:name,
|
||||
:parent_id,
|
||||
:creator_id,
|
||||
:approval_status,
|
||||
:request_notes,
|
||||
:reason_for_rejection,
|
||||
:rejection_notes, scientific_names_attributes: [:scientific_name,
|
||||
:_destroy,
|
||||
:id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,7 +87,9 @@ class GardensController < ApplicationController
|
||||
expire_fragment("homepage_stats")
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to gardens_by_owner_path(owner: @garden.owner), notice: 'Garden was successfully deleted.' }
|
||||
format.html do
|
||||
redirect_to gardens_by_owner_path(owner: @garden.owner), notice: 'Garden was successfully deleted.'
|
||||
end
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,11 @@ class MembersController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.haml
|
||||
format.json { render json: @members.to_json(only: [:id, :login_name, :slug, :bio, :created_at, :location, :latitude, :longitude]) }
|
||||
format.json {
|
||||
render json: @members.to_json(only: [
|
||||
:id, :login_name, :slug, :bio, :created_at, :location, :latitude, :longitude
|
||||
])
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +36,11 @@ class MembersController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.haml
|
||||
format.json { render json: @member.to_json(only: [:id, :login_name, :bio, :created_at, :slug, :location, :latitude, :longitude]) }
|
||||
format.json {
|
||||
render json: @member.to_json(only: [
|
||||
:id, :login_name, :bio, :created_at, :slug, :location, :latitude, :longitude
|
||||
])
|
||||
}
|
||||
format.rss { render(
|
||||
layout: false,
|
||||
locals: { member: @member }
|
||||
|
||||
@@ -5,7 +5,11 @@ class PlacesController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.html
|
||||
# json response is whatever we want to map here
|
||||
format.json { render json: Member.located.to_json(only: [:id, :login_name, :slug, :location, :latitude, :longitude]) }
|
||||
format.json do
|
||||
render json: Member.located.to_json(only: [
|
||||
:id, :login_name, :slug, :location, :latitude, :longitude
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +20,11 @@ class PlacesController < ApplicationController
|
||||
@nearby_members = Member.nearest_to(params[:place])
|
||||
respond_to do |format|
|
||||
format.html # show.html.haml
|
||||
format.json { render json: @nearby_members.to_json(only: [:id, :login_name, :slug, :location, :latitude, :longitude]) }
|
||||
format.json do
|
||||
render json: @nearby_members.to_json(only: [
|
||||
:id, :login_name, :slug, :location, :latitude, :longitude
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ class PlantingsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @planting.save
|
||||
@planting.update_attribute(:days_before_maturity, update_days_before_maturity(@planting, planting_params[:crop_id]))
|
||||
@planting.update_attribute(:days_before_maturity,
|
||||
update_days_before_maturity(@planting, planting_params[:crop_id]))
|
||||
format.html { redirect_to @planting, notice: 'Planting was successfully created.' }
|
||||
format.json { render json: @planting, status: :created, location: @planting }
|
||||
expire_fragment("homepage_stats")
|
||||
@@ -90,7 +91,8 @@ class PlantingsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @planting.update(planting_params)
|
||||
@planting.update_attribute(:days_before_maturity, update_days_before_maturity(@planting, planting_params[:crop_id]))
|
||||
@planting.update_attribute(:days_before_maturity,
|
||||
update_days_before_maturity(@planting, planting_params[:crop_id]))
|
||||
format.html { redirect_to @planting, notice: 'Planting was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
|
||||
@@ -13,9 +13,14 @@ module AutoSuggestHelper
|
||||
source_path = Rails.application.routes.url_helpers.send("#{source}s_search_path")
|
||||
|
||||
%Q{
|
||||
<input id="#{source}" class="auto-suggest #{options[:class]}" type="text" value="#{default}" data-source-url="#{source_path}", placeholder="e.g. lettuce">
|
||||
<noscript class="text-warning">Warning: Javascript must be available to search and match crops</noscript>
|
||||
<input id="#{resource}_#{source}_id" class="auto-suggest-id" type="hidden" name="#{resource}[#{source}_id]" value="#{default_id}">
|
||||
<input id="#{source}" class="auto-suggest #{options[:class]}"
|
||||
type="text" value="#{default}" data-source-url="#{source_path}",
|
||||
placeholder="e.g. lettuce">
|
||||
<noscript class="text-warning">
|
||||
Warning: Javascript must be available to search and match crops
|
||||
</noscript>
|
||||
<input id="#{resource}_#{source}_id" class="auto-suggest-id"
|
||||
type="hidden" name="#{resource}[#{source}_id]" value="#{default_id}">
|
||||
}.html_safe
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ module GardensHelper
|
||||
if garden.description.nil?
|
||||
"no description provided."
|
||||
else
|
||||
truncate(garden.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", garden_path(garden) }
|
||||
truncate(garden.description, length: 130, separator: ' ', omission: '... ') do
|
||||
link_to "Read more", garden_path(garden)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ class Notifier < ActionMailer::Base
|
||||
default from: "Growstuff <noreply@growstuff.org>"
|
||||
|
||||
def verifier
|
||||
raise "RAILS_SECRET_TOKEN environment variable not set - have you created config/application.yml?" unless ENV['RAILS_SECRET_TOKEN']
|
||||
unless ENV['RAILS_SECRET_TOKEN']
|
||||
raise "RAILS_SECRET_TOKEN environment variable"\
|
||||
"not set - have you created config/application.yml?"
|
||||
end
|
||||
|
||||
return ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN'])
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Crop < ActiveRecord::Base
|
||||
class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
|
||||
extend FriendlyId
|
||||
friendly_id :name, use: [:slugged, :finders]
|
||||
|
||||
@@ -22,10 +22,19 @@ class Crop < ActiveRecord::Base
|
||||
before_destroy {|crop| crop.posts.clear}
|
||||
|
||||
default_scope { order("lower(name) asc") }
|
||||
scope :recent, -> { where(approval_status: "approved").reorder("created_at desc") }
|
||||
scope :toplevel, -> { where(approval_status: "approved", parent_id: nil) }
|
||||
scope :popular, -> { where(approval_status: "approved").reorder("plantings_count desc, lower(name) asc") }
|
||||
scope :randomized, -> { where(approval_status: "approved").reorder('random()') } # ok on sqlite and psql, but not on mysql
|
||||
scope :recent, lambda {
|
||||
where(approval_status: "approved").reorder("created_at desc")
|
||||
}
|
||||
scope :toplevel, lambda {
|
||||
where(approval_status: "approved", parent_id: nil)
|
||||
}
|
||||
scope :popular, lambda {
|
||||
where(approval_status: "approved").reorder("plantings_count desc, lower(name) asc")
|
||||
}
|
||||
scope :randomized, lambda {
|
||||
# ok on sqlite and psql, but not on mysql
|
||||
where(approval_status: "approved").reorder('random()')
|
||||
}
|
||||
scope :pending_approval, -> { where(approval_status: "pending") }
|
||||
scope :approved, -> { where(approval_status: "approved") }
|
||||
scope :rejected, -> { where(approval_status: "rejected") }
|
||||
|
||||
@@ -125,7 +125,8 @@ class Harvest < ActiveRecord::Base
|
||||
end
|
||||
|
||||
if self.weight_quantity
|
||||
string += " weighing #{number_to_human(self.weight_quantity, strip_insignificant_zeros: true)} #{self.weight_unit}"
|
||||
string += " weighing #{number_to_human(self.weight_quantity, strip_insignificant_zeros: true)}"\
|
||||
" #{self.weight_unit}"
|
||||
end
|
||||
|
||||
return string
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
development:
|
||||
adapter: postgresql
|
||||
database: growstuff_dev
|
||||
host: localhost
|
||||
user: postgres
|
||||
password: postgres
|
||||
|
||||
test:
|
||||
adapter: postgresql
|
||||
database: growstuff_test
|
||||
host: localhost
|
||||
user: postgres
|
||||
password: postgres
|
||||
|
||||
production:
|
||||
adapter: postgresql
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# rubocop:disable Metrics/LineLength
|
||||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
Devise.setup do |config|
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
Growstuff::Application.routes.draw do
|
||||
Growstuff::Application.routes.draw do # rubocop:disable Metrics/BlockLength
|
||||
|
||||
get '/robots.txt' => 'robots#robots'
|
||||
|
||||
resources :plant_parts
|
||||
|
||||
devise_for :members, controllers: { registrations: "registrations", passwords: "passwords", sessions: "sessions", omniauth_callbacks: "omniauth_callbacks" }
|
||||
devise_for :members, controllers: {
|
||||
registrations: "registrations",
|
||||
passwords: "passwords",
|
||||
sessions: "sessions",
|
||||
omniauth_callbacks: "omniauth_callbacks"
|
||||
}
|
||||
devise_scope :member do
|
||||
get '/members/unsubscribe/:message' => 'members#unsubscribe', :as => 'unsubscribe_member'
|
||||
end
|
||||
|
||||
@@ -128,14 +128,18 @@ namespace :growstuff do
|
||||
puts "Adding products..."
|
||||
Product.find_or_create_by(
|
||||
name: "Annual subscription",
|
||||
description: "An annual subscription gives you access to paid account features for one year. Does not auto-renew.",
|
||||
description: "An annual subscription gives you access "\
|
||||
"to paid account features for one year. Does not auto-renew.",
|
||||
min_price: 3000,
|
||||
account_type_id: @paid_account.id,
|
||||
paid_months: 12
|
||||
)
|
||||
Product.find_or_create_by(
|
||||
name: "Seed account",
|
||||
description: "A seed account helps Growstuff grow in its early days. It gives you all the features of a paid account, in perpetuity. This account type never expires.",
|
||||
description: "A seed account helps Growstuff grow in its "\
|
||||
"early days. It gives you all the features of "\
|
||||
"a paid account, in perpetuity. This account "\
|
||||
"type never expires.",
|
||||
min_price: 15000,
|
||||
account_type_id: @seed_account.id,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
||||
# This command will automatically be run when you run "rails"
|
||||
# with Rails 3 gems installed from the root of your application.
|
||||
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
|
||||
@@ -20,7 +20,8 @@ feature "products" do
|
||||
click_link "New Product"
|
||||
expect(current_path).to eq new_product_path
|
||||
fill_in 'Name', with: 'Special offer'
|
||||
# note that failing to fill in a mandatory field has a messy error. This is not a priority defect but should be raised at some point.
|
||||
# note that failing to fill in a mandatory field has a messy error.
|
||||
# This is not a priority defect but should be raised at some point.
|
||||
fill_in 'Minimum price', with: '150'
|
||||
click_button 'Save'
|
||||
expect(current_path).to eq product_path(Product.last)
|
||||
|
||||
@@ -137,11 +137,13 @@ feature "crop detail page", js: true do
|
||||
end
|
||||
|
||||
scenario "has a link to OpenFarm" do
|
||||
expect(page).to have_link "OpenFarm - Growing guide", href: "https://openfarm.cc/en/crops/#{URI.escape crop.name}"
|
||||
expect(page).to have_link "OpenFarm - Growing guide",
|
||||
href: "https://openfarm.cc/en/crops/#{URI.escape crop.name}"
|
||||
end
|
||||
|
||||
scenario "has a link to gardenate" do
|
||||
expect(page).to have_link "Gardenate - Planting reminders", href: "http://www.gardenate.com/plant/#{URI.escape crop.name}"
|
||||
expect(page).to have_link "Gardenate - Planting reminders",
|
||||
href: "http://www.gardenate.com/plant/#{URI.escape crop.name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,7 @@ feature 'Plantings RSS feed' do
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit plantings_path(format: 'rss')
|
||||
expect(page).to have_content "Recent plantings from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
expect(page).to have_content "Recent plantings from "\
|
||||
"#{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,7 @@ feature 'Posts RSS feed' do
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit posts_path(format: 'rss')
|
||||
expect(page).to have_content "Recent posts from #{ @author ? @author : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
expect(page).to have_content "Recent posts from "\
|
||||
"#{ @author ? @author : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,7 @@ feature 'Seeds RSS feed' do
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit seeds_path(format: 'rss')
|
||||
expect(page).to have_content "Recent seeds from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
expect(page).to have_content "Recent seeds from "\
|
||||
"#{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,9 @@ describe CropsHelper do
|
||||
end
|
||||
|
||||
it 'should render' do
|
||||
expect(helper.display_seed_availability(@member, @crop)).to eq "You have an unknown quantity of seeds of this crop."
|
||||
expect(
|
||||
helper.display_seed_availability(@member, @crop)
|
||||
).to eq "You have an unknown quantity of seeds of this crop."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -597,8 +597,17 @@ describe Crop do
|
||||
end
|
||||
|
||||
context "crop rejections" do
|
||||
let!(:rejected_reason) { FactoryGirl.create(:crop, name: 'tomato', approval_status: 'rejected', reason_for_rejection: 'not edible') }
|
||||
let!(:rejected_other) { FactoryGirl.create(:crop, name: 'tomato', approval_status: 'rejected', reason_for_rejection: 'other', rejection_notes: 'blah blah blah') }
|
||||
let!(:rejected_reason) do
|
||||
FactoryGirl.create(:crop, name: 'tomato',
|
||||
approval_status: 'rejected',
|
||||
reason_for_rejection: 'not edible')
|
||||
end
|
||||
let!(:rejected_other) do
|
||||
FactoryGirl.create(:crop, name: 'tomato',
|
||||
approval_status: 'rejected',
|
||||
reason_for_rejection: 'other',
|
||||
rejection_notes: 'blah blah blah')
|
||||
end
|
||||
|
||||
describe "rejecting a crop" do
|
||||
it "should give reason if a default option" do
|
||||
|
||||
@@ -48,7 +48,10 @@ describe Seed do
|
||||
it 'should refuse invalid tradable_to values' do
|
||||
@seed = FactoryGirl.build(:seed, tradable_to: 'not valid')
|
||||
@seed.should_not be_valid
|
||||
@seed.errors[:tradable_to].should include("You may only trade seed nowhere, locally, nationally, or internationally")
|
||||
@seed.errors[:tradable_to].should include(
|
||||
"You may only trade seed nowhere, locally, "\
|
||||
"nationally, or internationally"
|
||||
)
|
||||
end
|
||||
|
||||
it 'should not allow nil or blank values' do
|
||||
|
||||
Reference in New Issue
Block a user