mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3347519593 | ||
|
|
e334fc449e | ||
|
|
f9ce3044ec | ||
|
|
9ec2d9d639 | ||
|
|
00b20e6643 | ||
|
|
ed21fbb1ee | ||
|
|
64d046c2fe | ||
|
|
b213647a43 | ||
|
|
ded6aca4b1 | ||
|
|
26189855cc | ||
|
|
7f16f51a47 | ||
|
|
f23289ec6e | ||
|
|
725c146e2d | ||
|
|
e3bb749e6d | ||
|
|
659c38eea3 | ||
|
|
c37c1c9f38 | ||
|
|
5f44dd7ab0 | ||
|
|
09b3654395 | ||
|
|
10335d51db | ||
|
|
c2e46d93fc | ||
|
|
5c67006cb8 | ||
|
|
47c6937db2 | ||
|
|
b5bab8bd0b | ||
|
|
1699d7f57a | ||
|
|
bbc9f3b1cc | ||
|
|
6d294823d1 | ||
|
|
2680d028ca | ||
|
|
6d057204e9 | ||
|
|
c568345307 | ||
|
|
c8eedb49fa | ||
|
|
41d3de7374 | ||
|
|
3fc72bd9db | ||
|
|
65d0d0893b |
@@ -93,6 +93,7 @@ submit the change with your pull request.
|
||||
- Martina Simicic / [simicic](https://github.com/simicic)
|
||||
- Rowan Crawford / [wombleton](https://github.com/wombleton)
|
||||
- Ítalo Pires / [italopires](https://github.com/italopires)
|
||||
- Bennett Zink / [bennett-zink](https://github.com/bennett-zink)
|
||||
|
||||
## Bots
|
||||
|
||||
|
||||
27
Gemfile.lock
27
Gemfile.lock
@@ -191,6 +191,7 @@ GEM
|
||||
marcel (~> 1.0.0)
|
||||
ssrf_filter (~> 1.0)
|
||||
chartkick (5.0.6)
|
||||
childprocess (5.0.0)
|
||||
codeclimate-test-reporter (1.0.9)
|
||||
simplecov (<= 0.13)
|
||||
coderay (1.1.3)
|
||||
@@ -258,7 +259,7 @@ GEM
|
||||
factory_bot_rails (6.4.3)
|
||||
factory_bot (~> 6.4)
|
||||
railties (>= 5.0.0)
|
||||
faker (3.3.0)
|
||||
faker (3.3.1)
|
||||
i18n (>= 1.8.11, < 2)
|
||||
faraday (2.9.0)
|
||||
faraday-net_http (>= 2.0, < 3.2)
|
||||
@@ -340,7 +341,7 @@ GEM
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (2.7.1)
|
||||
json (2.7.2)
|
||||
json-schema (4.1.1)
|
||||
addressable (>= 2.8)
|
||||
jsonapi-resources (0.10.7)
|
||||
@@ -352,13 +353,14 @@ GEM
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
language_server-protocol (3.17.0.3)
|
||||
launchy (2.5.2)
|
||||
launchy (3.0.0)
|
||||
addressable (~> 2.8)
|
||||
childprocess (~> 5.0)
|
||||
leaflet-rails (1.9.4)
|
||||
actionpack (>= 4.2.0)
|
||||
railties (>= 4.2.0)
|
||||
letter_opener (1.9.0)
|
||||
launchy (>= 2.2, < 3)
|
||||
letter_opener (1.10.0)
|
||||
launchy (>= 2.2, < 4)
|
||||
listen (3.9.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
@@ -444,7 +446,7 @@ GEM
|
||||
method_source (~> 1.0)
|
||||
psych (5.1.2)
|
||||
stringio
|
||||
public_suffix (5.0.4)
|
||||
public_suffix (5.0.5)
|
||||
puma (6.4.2)
|
||||
nio4r (~> 2.0)
|
||||
query_diet (0.7.1)
|
||||
@@ -505,7 +507,7 @@ GEM
|
||||
zeitwerk (~> 2.6)
|
||||
rainbow (3.1.1)
|
||||
raindrops (0.20.0)
|
||||
rake (13.1.0)
|
||||
rake (13.2.1)
|
||||
rate_throttle_client (0.1.2)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
@@ -562,7 +564,7 @@ GEM
|
||||
rswag-ui (2.13.0)
|
||||
actionpack (>= 3.1, < 7.2)
|
||||
railties (>= 3.1, < 7.2)
|
||||
rubocop (1.62.1)
|
||||
rubocop (1.63.0)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
@@ -584,10 +586,13 @@ GEM
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.33.0, < 2.0)
|
||||
rubocop-ast (>= 1.31.1, < 2.0)
|
||||
rubocop-rspec (2.27.1)
|
||||
rubocop-rspec (2.29.1)
|
||||
rubocop (~> 1.40)
|
||||
rubocop-capybara (~> 2.17)
|
||||
rubocop-factory_bot (~> 2.22)
|
||||
rubocop-rspec_rails (~> 2.28)
|
||||
rubocop-rspec_rails (2.28.2)
|
||||
rubocop (~> 1.40)
|
||||
ruby-progressbar (1.13.0)
|
||||
ruby-units (4.0.3)
|
||||
ruby-vips (2.2.1)
|
||||
@@ -606,7 +611,7 @@ GEM
|
||||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
scout_apm (5.3.7)
|
||||
scout_apm (5.3.8)
|
||||
parser
|
||||
searchkick (5.3.1)
|
||||
activemodel (>= 6.1)
|
||||
@@ -641,7 +646,7 @@ GEM
|
||||
temple (0.10.3)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
terser (1.2.1)
|
||||
terser (1.2.2)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
thor (1.3.1)
|
||||
thread_safe (0.3.6)
|
||||
|
||||
@@ -102,16 +102,14 @@ section {
|
||||
box-shadow: 1px 3px 3px 1px darken($beige, 20%);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
0.3s transform cubic-bezier(0.155, 1.105, 0.295, 1.12),
|
||||
0.3s box-shadow,
|
||||
0.3s -webkit-transform cubic-bezier(0.155, 1.105, 0.295, 1.12);
|
||||
0.1s transform cubic-bezier(0.155, 1.105, 0.295, 1.12),
|
||||
0.1s box-shadow,
|
||||
0.1s -webkit-transform cubic-bezier(0.155, 1.105, 0.295, 1.12);
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
box-shadow:
|
||||
0 10px 20px darken($beige, 30%),
|
||||
0 4px 8px darken($beige, 40%);
|
||||
transform: scale(1.1);
|
||||
1px 3px 3px 1px darken($beige, 30%);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,10 +146,6 @@ section {
|
||||
color: $brown;
|
||||
}
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
background-color: $beige;
|
||||
}
|
||||
}
|
||||
|
||||
.img-cover,
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
# Working from codespaces, we want to turn off validation
|
||||
if Rails.env.development? && ENV['CODESPACE_NAME']
|
||||
skip_before_action :verify_authenticity_token
|
||||
end
|
||||
|
||||
include ApplicationHelper
|
||||
|
||||
|
||||
@@ -153,5 +153,10 @@ class Ability
|
||||
can :destroy, PlantPart do |pp|
|
||||
pp.harvests.empty?
|
||||
end
|
||||
# Admins can't delete themselves
|
||||
cannot :destroy, Member
|
||||
can :destroy, Member do |other_member|
|
||||
other_member&.id != member.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class Photo < ApplicationRecord
|
||||
|
||||
has_many :photo_associations, dependent: :delete_all, inverse_of: :photo
|
||||
|
||||
# This doesn't work, ActiveRecord tries to use the polymoriphinc photographable
|
||||
# This doesn't work, ActiveRecord tries to use the polymoriphic photographable
|
||||
# relationship instead.
|
||||
# has_many :crops, through: :photo_associations, counter_cache: true
|
||||
def crops
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
.col
|
||||
%p
|
||||
- if current_member.plantings.active.any?
|
||||
= link_to member_path(current_member), class: 'btn btn-dark' do
|
||||
= link_to member_path(current_member, anchor: "#content"), class: 'btn btn-dark' do
|
||||
= planting_icon
|
||||
Track my plantings
|
||||
%p
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
%nav.navbar.navbar-expand-lg.navbar-dark.bg-dark.justify-content-between
|
||||
%nav.navbar.navbar-expand-lg.navbar-dark.bg-dark.justify-content-between.sticky-top
|
||||
.nav
|
||||
%a.navbar-brand{ href: root_path }
|
||||
= image_tag("pear.png", class: 'logo', alt: 'Growstuff brand logo (drawing of a pear)')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
%html{ lang: "en", prefix: "og: https://ogp.me/ns#" }
|
||||
= yield :scripts
|
||||
= render "layouts/head"
|
||||
%body
|
||||
%body.d-flex.flex-column.vh-100
|
||||
= query_diet_widget if Rails.env.development?
|
||||
.sr-only= link_to t(".skip"), "#skipnav"
|
||||
= render "layouts/header"
|
||||
@@ -25,7 +25,7 @@
|
||||
= render "shared/flash_messages", flash: flash
|
||||
%main= yield
|
||||
|
||||
%footer.page-footer.font-small.bg-dark.pt-4= render "layouts/footer"
|
||||
%footer.page-footer.font-small.bg-dark.pt-4.mt-auto= render "layouts/footer"
|
||||
/
|
||||
Javascripts
|
||||
\==================================================
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
%h2 All about #{member.login_name}
|
||||
%p
|
||||
%small
|
||||
%a{href: "#content"}
|
||||
Skip to main content
|
||||
- if member.bio.blank?
|
||||
- if can? :edit, member
|
||||
= link_to "Add a bio to complete your profile.", edit_member_path(member)
|
||||
= link_to "Add a bio to complete your profile.", edit_member_registration_path
|
||||
- else
|
||||
#{member.login_name} hasn't written a bio yet.
|
||||
- else
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
- if @harvesting.size.positive?
|
||||
%section.harvests
|
||||
%h2 Ready to harvest
|
||||
.index-cards
|
||||
- @harvesting.each do |planting|
|
||||
= render 'plantings/thumbnail', planting: planting
|
||||
|
||||
- if @others.size.positive?
|
||||
%section.planting-progress
|
||||
%h2 Progress report
|
||||
%p Still growing and not ready for harvesting.
|
||||
.list-group
|
||||
- @others.each do |planting|
|
||||
.list-group-item
|
||||
%span= render 'plantings/tiny', planting: planting
|
||||
%span= render 'plantings/progress', planting: planting
|
||||
- if @late.size.positive?
|
||||
%section.late
|
||||
%h2 Late
|
||||
%p
|
||||
These plantings are at the end of their lifecycle.
|
||||
- if member_signed_in? && @member == current_member
|
||||
%strong When you have removed the planting from your garden, mark the planting as finished in Growstuff.
|
||||
.index-cards
|
||||
- @late.each do |planting|
|
||||
= render 'plantings/thumbnail', planting: planting
|
||||
- if @super_late.any?
|
||||
%section.superlate
|
||||
%h2 Super late
|
||||
%p
|
||||
We suspect the following plantings finished long ago and no longer need tracking.
|
||||
- if member_signed_in? && current_member == @member
|
||||
%strong You can mark these plantings as finished to stop tracking.
|
||||
%ul
|
||||
- @super_late.each do |planting|
|
||||
%li
|
||||
= link_to planting.crop_name, planting_url(slug: planting.slug)
|
||||
planted on #{planting.planted_at.to_date}
|
||||
|
||||
- if @harvests.any?
|
||||
%section.havests
|
||||
%h2 Recent Harvests
|
||||
.index-cards
|
||||
- @harvests.each do |harvest|
|
||||
= render 'harvests/thumbnail', harvest: harvest
|
||||
|
||||
@@ -1,45 +1,33 @@
|
||||
.card-body
|
||||
%h3 Activity
|
||||
%ul.list-group.list-group-flush
|
||||
%li.list-group-item
|
||||
%h3
|
||||
Stats
|
||||
.label.d-md-none{type: "button", :data => { :bs_toggle => "collapse", :bs_target => "#stats-collapse"}}
|
||||
%a
|
||||
Show/Hide
|
||||
|
||||
.collapse.d-md-block#stats-collapse
|
||||
%ul.list-group.list-group-flush
|
||||
- if member.gardens.present?
|
||||
= link_to localize_plural(member.gardens, Garden), member_gardens_path(member)
|
||||
- else
|
||||
0 gardens
|
||||
%li.list-group-item
|
||||
%li.list-group-item
|
||||
= link_to localize_plural(member.gardens, Garden), member_gardens_path(member)
|
||||
- if member.plantings.present?
|
||||
= link_to localize_plural(member.plantings, Planting), member_plantings_path(member)
|
||||
- else
|
||||
0 plantings
|
||||
%li.list-group-item
|
||||
%li.list-group-item
|
||||
= link_to localize_plural(member.plantings, Planting), member_plantings_path(member)
|
||||
- if member.harvests.present?
|
||||
= link_to localize_plural(member.harvests, Harvest), member_harvests_path(member)
|
||||
- else
|
||||
0 harvests
|
||||
%li.list-group-item
|
||||
%li.list-group-item
|
||||
= link_to localize_plural(member.harvests, Harvest), member_harvests_path(member)
|
||||
- if member.seeds.present?
|
||||
= link_to localize_plural(member.seeds, Seed), member_seeds_path(member)
|
||||
- else
|
||||
0 seeds
|
||||
%li.list-group-item
|
||||
%li.list-group-item
|
||||
= link_to localize_plural(member.seeds, Seed), member_seeds_path(member)
|
||||
- if member.posts.present?
|
||||
= link_to localize_plural(member.posts, Post), member_posts_path(member)
|
||||
- else
|
||||
0 posts
|
||||
%li.list-group-item
|
||||
%li.list-group-item
|
||||
= link_to localize_plural(member.posts, Post), member_posts_path(member)
|
||||
- if member.activities.present?
|
||||
= link_to localize_plural(member.plantings, Activity), member_activities_path(member)
|
||||
- else
|
||||
0 activities
|
||||
|
||||
%li.list-group-item
|
||||
%li.list-group-item
|
||||
= link_to localize_plural(member.plantings, Activity), member_activities_path(member)
|
||||
- if member.followed.present?
|
||||
= link_to localize_plural(member.followed, Follow), member_follows_path(member)
|
||||
- else
|
||||
0 following
|
||||
|
||||
%li.list-group-item
|
||||
%li.list-group-item
|
||||
= link_to localize_plural(member.followed, Follow), member_follows_path(member)
|
||||
- if member.followers.present?
|
||||
= link_to pluralize(member.followers.size, "follower"), member_followers_path(member)
|
||||
- else
|
||||
0 followers
|
||||
%li.list-group-item
|
||||
= link_to pluralize(member.followers.size, "follower"), member_followers_path(member)
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
.row
|
||||
.col= render "bio", member: @member
|
||||
.col= render "avatar", member: @member
|
||||
%p
|
||||
- @member.roles.each do |role|
|
||||
%span.badge.badge-info= role.name.titleize
|
||||
- if @member.roles.any?
|
||||
%p
|
||||
- @member.roles.each do |role|
|
||||
%span.badge.badge-info= role.name.titleize
|
||||
- if @member.location.present?
|
||||
%p.badge.badge-location{ title: @member.location }
|
||||
= icon 'fas', 'map-marker'
|
||||
@@ -31,9 +32,10 @@
|
||||
%p
|
||||
%strong Member since
|
||||
= @member.created_at.to_fs(:date)
|
||||
%p
|
||||
%strong Last Login
|
||||
= @member.last_sign_in_at
|
||||
- if @member.last_sign_in_at
|
||||
%p
|
||||
%strong Last Login
|
||||
= @member.last_sign_in_at
|
||||
|
||||
- if can? :update, @member
|
||||
= link_to edit_member_registration_path, class: 'btn btn-block' do
|
||||
@@ -59,24 +61,71 @@
|
||||
= render "contact", member: @member, twitter_auth: @twitter_auth,
|
||||
flickr_auth: @flickr_auth
|
||||
|
||||
.col-md-10
|
||||
%section= render "map", member: @member
|
||||
= render 'members/full_summary', member: @member
|
||||
%section.activity
|
||||
%h2 Activity
|
||||
.list-group
|
||||
- @activity.each do |event|
|
||||
.list-group-item.list-group-item-action.flex-column.align-items-start{:href => "#!"}
|
||||
.d-flex.w-100.justify-content-between
|
||||
%h5
|
||||
= icon_for_model(event.event_type)
|
||||
= event_description(event)
|
||||
= render 'timeline/photos', photo: resolve_model(event) if event.event_type == 'photo'
|
||||
%small
|
||||
- if event.event_at.present?
|
||||
- if event.event_at.kind_of?(Date)
|
||||
#{distance_of_time_in_words(event.event_at, Time.zone.now.to_date)} ago
|
||||
- else
|
||||
#{time_ago_in_words(event.event_at)} ago
|
||||
- else
|
||||
unknown date
|
||||
.col-md-10#content
|
||||
.row
|
||||
%section.order-3.order-md-1.col-12= render "map", member: @member
|
||||
- if @harvesting.size.positive?
|
||||
%section.harvests.order-2.order-md-1
|
||||
%h2 Ready to harvest
|
||||
.index-cards
|
||||
- @harvesting.each do |planting|
|
||||
= render 'plantings/thumbnail', planting: planting
|
||||
|
||||
- if @others.size.positive?
|
||||
%section.planting-progress.order-2.order-md-1.col-12
|
||||
%h2 Progress report
|
||||
%p Still growing and not ready for harvesting.
|
||||
.list-group
|
||||
- @others.each do |planting|
|
||||
.list-group-item
|
||||
%span= render 'plantings/tiny', planting: planting
|
||||
%span= render 'plantings/progress', planting: planting
|
||||
- if @late.size.positive?
|
||||
%section.late.order-2.order-md-1.col-12
|
||||
%h2 Late
|
||||
%p
|
||||
These plantings are at the end of their lifecycle.
|
||||
- if member_signed_in? && @member == current_member
|
||||
%strong When you have removed the planting from your garden, mark the planting as finished in Growstuff.
|
||||
.index-cards
|
||||
- @late.each do |planting|
|
||||
= render 'plantings/thumbnail', planting: planting
|
||||
- if @super_late.any?
|
||||
%section.superlate.order-2.order-md-1.col-12
|
||||
%h2 Super late
|
||||
%p
|
||||
We suspect the following plantings finished long ago and no longer need tracking.
|
||||
- if member_signed_in? && current_member == @member
|
||||
%strong You can mark these plantings as finished to stop tracking.
|
||||
%ul
|
||||
- @super_late.each do |planting|
|
||||
%li
|
||||
= link_to planting.crop_name, planting_url(slug: planting.slug)
|
||||
planted on #{planting.planted_at.to_date}
|
||||
|
||||
- if @harvests.any?
|
||||
%section.havests.order-2.order-md-1.col-12
|
||||
%h2 Recent Harvests
|
||||
.index-cards
|
||||
- @harvests.each do |harvest|
|
||||
= render 'harvests/thumbnail', harvest: harvest
|
||||
|
||||
- if @activity.any?
|
||||
%section.activity.order-2.order-md-1.col-12
|
||||
%h2 Activity
|
||||
.list-group
|
||||
- @activity.each do |event|
|
||||
.list-group-item.list-group-item-action.flex-column.align-items-start{:href => "#!"}
|
||||
.d-flex.w-100.justify-content-between
|
||||
%h5.col-md-11.col-xs-10.text-truncate
|
||||
= icon_for_model(event.event_type)
|
||||
= event_description(event)
|
||||
= render 'timeline/photos', photo: resolve_model(event) if event.event_type == 'photo'
|
||||
%small.col-md-1.col-xs-2.text-right
|
||||
- if event.event_at.present?
|
||||
- if event.event_at.kind_of?(Date)
|
||||
#{distance_of_time_in_words(event.event_at, Time.zone.now.to_date)} ago
|
||||
- else
|
||||
#{time_ago_in_words(event.event_at)} ago
|
||||
- else
|
||||
unknown date
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
%hr/
|
||||
%p Yes, I would be willing trade these from #{current_member.location}
|
||||
|
||||
.btn-group{"aria-label" => "trade to", role: "group"}
|
||||
- Seed::TRADABLE_TO_VALUES.each do |t|
|
||||
.btn-group.d-grid.flex-column{"aria-label" => "trade to", role: "group"}
|
||||
- Seed::TRADABLE_TO_VALUES.reverse.each do |t|
|
||||
- unless t == 'nowhere'
|
||||
= button_to seeds_path(seed: {crop_id: seed.crop_id, tradable_to: t}), method: :post, class: 'btn' do
|
||||
%h3= t
|
||||
= button_to seeds_path(seed: {crop_id: seed.crop_id, tradable_to: t}), method: :post, class: 'btn col-12' do
|
||||
= t
|
||||
|
||||
%hr/
|
||||
%p
|
||||
|
||||
@@ -67,7 +67,11 @@ Rails.application.configure do
|
||||
config.action_mailer.delivery_method = :letter_opener
|
||||
|
||||
config.host = 'localhost:3000'
|
||||
config.hosts << ".preview.app.github.dev"
|
||||
if ENV['CODESPACE_NAME']
|
||||
config.host = "#{ENV['CODESPACE_NAME']}-3000.app.github.dev:443"
|
||||
config.hosts << ".preview.app.github.dev"
|
||||
config.hosts << ".app.github.dev"
|
||||
end
|
||||
config.analytics_code = ''
|
||||
|
||||
config.action_controller.action_on_unpermitted_parameters = :raise
|
||||
|
||||
121
db/seeds.rb
121
db/seeds.rb
@@ -44,6 +44,7 @@ def load_roles
|
||||
end
|
||||
|
||||
def load_test_users
|
||||
require "faker"
|
||||
puts "Loading test users..."
|
||||
|
||||
# Open suburb csv
|
||||
@@ -80,24 +81,114 @@ def load_test_users
|
||||
end
|
||||
|
||||
# Create a planting by the member
|
||||
Planting.create(
|
||||
owner_id: @user.id,
|
||||
garden_id: @user.gardens.first.id,
|
||||
planted_at: Time.zone.today,
|
||||
crop_id: Crop.find(i % Crop.all.size + 1).id,
|
||||
sunniness: select_random_item(Planting::SUNNINESS_VALUES),
|
||||
planted_from: select_random_item(Planting::PLANTED_FROM_VALUES)
|
||||
)
|
||||
10.times do |n|
|
||||
planting = Planting.create!(
|
||||
owner_id: @user.id,
|
||||
garden_id: @user.gardens.first.id,
|
||||
planted_at: (n * 7).days.ago,
|
||||
crop_id: Crop.find((i + n) % Crop.all.size + 1).id,
|
||||
sunniness: select_random_item(Planting::SUNNINESS_VALUES),
|
||||
planted_from: select_random_item(Planting::PLANTED_FROM_VALUES)
|
||||
)
|
||||
photo = Photo.create!(
|
||||
owner: @user,
|
||||
source: 'flickr',
|
||||
source_id: 1,
|
||||
title: Faker::Movies::HarryPotter.quote,
|
||||
license_name: "CC-BY",
|
||||
license_url: "http://example.com/license.html",
|
||||
thumbnail_url: "https://picsum.photos/200?planting-#{planting.id}",
|
||||
fullsize_url: "https://picsum.photos/600?planting-#{planting.id}",
|
||||
link_url: Faker::Internet.url
|
||||
)
|
||||
planting.photos << photo
|
||||
end
|
||||
|
||||
# Create an activity by the member
|
||||
Activity.create(
|
||||
owner_id: @user.id,
|
||||
garden_id: @user.gardens.first.id,
|
||||
due_date: Time.zone.today,
|
||||
name: "Remove all weeds",
|
||||
category: "Weeding",
|
||||
description: "Get rid of the invasive grass, again"
|
||||
3.times do |_n|
|
||||
Activity.create!(
|
||||
owner_id: @user.id,
|
||||
garden_id: @user.gardens.first.id,
|
||||
due_date: Time.zone.today,
|
||||
name: Faker::Book.title,
|
||||
category: "Weeding",
|
||||
description: Faker::Lorem.paragraphs.join("\n")
|
||||
)
|
||||
end
|
||||
|
||||
# Create a post by the member
|
||||
post = Post.create!(
|
||||
author_id: @user.id,
|
||||
subject: Faker::Book.title,
|
||||
body: Faker::Lorem.paragraphs.join("\n")
|
||||
)
|
||||
photo = Photo.create!(
|
||||
owner: @user,
|
||||
source: 'flickr',
|
||||
source_id: 1,
|
||||
title: Faker::Movies::HarryPotter.quote,
|
||||
license_name: "CC-BY",
|
||||
license_url: "http://example.com/license.html",
|
||||
thumbnail_url: "https://picsum.photos/200?post-#{post.id}",
|
||||
fullsize_url: "https://picsum.photos/600?post-#{post.id}",
|
||||
link_url: Faker::Internet.url
|
||||
)
|
||||
post.photos << photo
|
||||
|
||||
2.times do
|
||||
harvest = Harvest.create!(
|
||||
crop: @user.plantings.last.crop,
|
||||
planting: @user.plantings.last,
|
||||
plant_part: select_random_item(PlantPart.all.to_a),
|
||||
owner: @user,
|
||||
harvested_at: 1.day.ago,
|
||||
quantity: "3",
|
||||
unit: "individual",
|
||||
weight_quantity: 6,
|
||||
weight_unit: "kg",
|
||||
description: Faker::Book.title
|
||||
)
|
||||
|
||||
photo = Photo.create!(
|
||||
owner: @user,
|
||||
source: 'flickr',
|
||||
source_id: 1,
|
||||
title: Faker::Movies::HarryPotter.quote,
|
||||
license_name: "CC-BY",
|
||||
license_url: "http://example.com/license.html",
|
||||
thumbnail_url: "https://picsum.photos/200?harvest-#{harvest.id}",
|
||||
fullsize_url: "https://picsum.photos/600?harvest-#{harvest.id}",
|
||||
link_url: Faker::Internet.url
|
||||
)
|
||||
harvest.photos << photo
|
||||
end
|
||||
|
||||
5.times do
|
||||
seed = Seed.create!(
|
||||
owner: @user,
|
||||
crop: @user.plantings.first.crop,
|
||||
description: Faker::Book.title,
|
||||
quantity: Faker::Number.number(digits: 3),
|
||||
tradable_to: select_random_item(Seed::TRADABLE_TO_VALUES),
|
||||
organic: select_random_item(Seed::ORGANIC_VALUES),
|
||||
gmo: select_random_item(['certified GMO-free', 'non-certified GMO-free', 'GMO', 'unknown']), # Strangely, this doesn't want to work as Seed:GMO_VALUES
|
||||
heirloom: select_random_item(Seed::HEIRLOOM_VALUES),
|
||||
parent_planting: @user.plantings.first
|
||||
)
|
||||
|
||||
photo = Photo.create!(
|
||||
owner: @user,
|
||||
source: 'flickr',
|
||||
source_id: 1,
|
||||
title: Faker::Movies::HarryPotter.quote,
|
||||
license_name: "CC-BY",
|
||||
license_url: "http://example.com/license.html",
|
||||
thumbnail_url: "https://picsum.photos/200?seed-#{seed.id}",
|
||||
fullsize_url: "https://picsum.photos/600?seed-#{seed.id}",
|
||||
link_url: Faker::Internet.url
|
||||
)
|
||||
seed.photos << photo
|
||||
end
|
||||
end
|
||||
|
||||
puts "Finished loading test users"
|
||||
|
||||
@@ -54,11 +54,11 @@ describe "member profile", :js do
|
||||
context "activity stats" do
|
||||
it "with no activity" do
|
||||
visit member_path(member)
|
||||
expect(page).to have_content "Activity"
|
||||
expect(page).to have_content "0 plantings"
|
||||
expect(page).to have_content "0 harvests"
|
||||
expect(page).to have_content "0 seeds"
|
||||
expect(page).to have_content "0 posts"
|
||||
expect(page).to have_content "Stats"
|
||||
expect(page).not_to have_content "0 plantings"
|
||||
expect(page).not_to have_content "0 harvests"
|
||||
expect(page).not_to have_content "0 seeds"
|
||||
expect(page).not_to have_content "0 posts"
|
||||
end
|
||||
|
||||
context "with some activity" do
|
||||
|
||||
@@ -118,4 +118,28 @@ describe Ability do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'members' do
|
||||
context 'ordinary member' do
|
||||
it "can't manage members" do
|
||||
ability.should_not be_able_to(:destroy, Member)
|
||||
end
|
||||
end
|
||||
|
||||
context 'admin' do
|
||||
let(:role) { FactoryBot.create(:admin) }
|
||||
|
||||
before do
|
||||
member.roles << role
|
||||
end
|
||||
|
||||
it "can manage members" do
|
||||
ability.should be_able_to(:destroy, FactoryBot.create(:member))
|
||||
end
|
||||
it "cannot delete themselves" do
|
||||
ability.should_not be_able_to(:destroy, member)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user