mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-29 19:51:00 -05:00
Merge branch 'dev' into garden-overview
This commit is contained in:
@@ -93,5 +93,4 @@ submit the change with your pull request.
|
||||
|
||||
### Security and Dependency Updates
|
||||
- DeppBot / [deppbot](https://github.com/deppbot)
|
||||
- dependabot[bot] / [dependabot-bot] / [dependabot] (https://github.com/dependabot-bot)
|
||||
- dependabot / [dependabot](https://github.com/dependabot)
|
||||
- dependabot[bot] (https://github.com/dependabot-bot)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env ruby
|
||||
require "English"
|
||||
|
||||
puts "Checking to see if you're in CONTRIBUTORS.md..."
|
||||
|
||||
if ENV['TRAVIS']
|
||||
if ENV['TRAVIS_PULL_REQUEST']
|
||||
require 'httparty'
|
||||
@@ -27,7 +29,10 @@ Please set it using
|
||||
end
|
||||
end
|
||||
|
||||
unless system('grep', '-i', author, 'CONTRIBUTORS.md')
|
||||
# Escape chars in name, and make case insensitive
|
||||
author_to_search_for = Regexp.new(Regexp.escape(author), Regexp::IGNORECASE)
|
||||
|
||||
unless File.read('CONTRIBUTORS.md').match?(author_to_search_for)
|
||||
abort %(
|
||||
Thanks for your contribution, #{author}!
|
||||
Please add your name and GitHub handle to the file CONTRIBUTORS.md,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe AuthenticationsController do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_member) { @member }
|
||||
|
||||
@@ -15,7 +15,7 @@ describe Charts::GardensController do
|
||||
end
|
||||
|
||||
context "when signed in" do
|
||||
before(:each) { sign_in member }
|
||||
before { sign_in member }
|
||||
|
||||
let!(:member) { FactoryBot.create(:member) }
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ describe CommentsController do
|
||||
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
sign_in member
|
||||
controller.stub(:current_member) { member }
|
||||
end
|
||||
@@ -35,12 +35,11 @@ describe CommentsController do
|
||||
describe "with valid params" do
|
||||
before { get :new, params: { post_id: post.id } }
|
||||
|
||||
let(:old_comment) { FactoryBot.create(:comment, post: post) }
|
||||
it "picks up post from params" do
|
||||
expect(assigns(:post)).to eq(post)
|
||||
end
|
||||
|
||||
let(:old_comment) { FactoryBot.create(:comment, post: post) }
|
||||
|
||||
it "assigns the old comments as @comments" do
|
||||
expect(assigns(:comments)).to eq [old_comment]
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ RSpec.describe GardensController, type: :controller do
|
||||
end
|
||||
|
||||
context "when signed in" do
|
||||
before(:each) { sign_in member }
|
||||
before { sign_in member }
|
||||
|
||||
let!(:member) { FactoryBot.create(:member) }
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ describe LikesController do
|
||||
before { sign_in member }
|
||||
|
||||
describe "POST create" do
|
||||
it { expect(response.content_type).to eq "application/json" }
|
||||
before { post :create, params: { post_id: blogpost.id, format: :json } }
|
||||
it { expect(response.content_type).to eq "application/json" }
|
||||
|
||||
it { expect(Like.last.likeable_id).to eq(blogpost.id) }
|
||||
it { expect(Like.last.likeable_type).to eq('Post') }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe MembersController do
|
||||
before :each do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
@posts = [FactoryBot.create(:post, author: @member)]
|
||||
@twitter_auth = FactoryBot.create(:authentication, member: @member)
|
||||
|
||||
@@ -30,7 +30,7 @@ describe PhotosController do
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
let!(:auth) { FactoryBot.create(:flickr_authentication, member: member) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
sign_in member
|
||||
member.stub(:flickr_photos) { [[], 0] }
|
||||
member.stub(:flickr_sets) { { "foo" => "bar" } }
|
||||
@@ -38,7 +38,7 @@ describe PhotosController do
|
||||
end
|
||||
|
||||
describe "planting photos" do
|
||||
before(:each) { get :new, params: { type: "planting", id: planting.id } }
|
||||
before { get :new, params: { type: "planting", id: planting.id } }
|
||||
|
||||
it { assigns(:flickr_auth).should be_an_instance_of(Authentication) }
|
||||
it { assigns(:item).should eq planting }
|
||||
@@ -62,7 +62,7 @@ describe PhotosController do
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
before(:each) do
|
||||
before do
|
||||
Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius",
|
||||
license_name: "CC-BY",
|
||||
license_url: "http://example.com/aybpl",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe PlacesController do
|
||||
before :each do
|
||||
before do
|
||||
controller.stub(:current_member) { nil }
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member_london = FactoryBot.create(:london_member)
|
||||
@member_south_pole = FactoryBot.create(:south_pole_member)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe RegistrationsController do
|
||||
before :each do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
|
||||
@@ -34,7 +34,7 @@ feature "Gardens#index", :js do
|
||||
it "show active garden" do
|
||||
expect(page).to have_text active_garden.name
|
||||
end
|
||||
it "should not show inactive garden" do
|
||||
it "does not show inactive garden" do
|
||||
expect(page).not_to have_text inactive_garden.name
|
||||
end
|
||||
it "links to active garden" do
|
||||
@@ -74,7 +74,7 @@ feature "Gardens#index", :js do
|
||||
let(:member) { FactoryBot.create :member, login_name: 'robbieburns' }
|
||||
let(:crop) { FactoryBot.create :crop }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
# time to harvest = 50 day
|
||||
# time to finished = 90 days
|
||||
FactoryBot.create(:harvest,
|
||||
|
||||
@@ -21,7 +21,7 @@ feature "browse harvests" do
|
||||
feature "filled in optional fields" do
|
||||
let!(:harvest) { create :harvest, :long_description }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
visit harvests_path
|
||||
end
|
||||
|
||||
|
||||
@@ -30,23 +30,23 @@ feature "User searches" do
|
||||
search_with "Philippines"
|
||||
end
|
||||
|
||||
it "should show that there are nearby seeds, plantings, and members" do
|
||||
it "shows that there are nearby seeds, plantings, and members" do
|
||||
expect(page).to have_content "Nearby members"
|
||||
expect(page).to have_content "Seeds available for trade near Philippines"
|
||||
expect(page).to have_content "Recent plantings near Philippines"
|
||||
end
|
||||
|
||||
it "should go to members' index page" do
|
||||
it "goes to members' index page" do
|
||||
click_link 'View all members >>'
|
||||
expect(current_path).to eq members_path
|
||||
end
|
||||
|
||||
it "should go to plantings' index page" do
|
||||
it "goes to plantings' index page" do
|
||||
click_link 'View all plantings >>'
|
||||
expect(current_path).to eq plantings_path
|
||||
end
|
||||
|
||||
it "should go to seeds' index page" do
|
||||
it "goes to seeds' index page" do
|
||||
click_link 'View all seeds >>'
|
||||
expect(current_path).to eq seeds_path
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
@a_future_date = 1.year.from_now.strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
it "should show that it is not planted yet" do
|
||||
it "shows that it is not planted yet" do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
@@ -80,7 +80,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
expect(page).to have_content "Progress: 0% - not planted yet"
|
||||
end
|
||||
|
||||
it "should show that days before maturity is unknown" do
|
||||
it "shows that days before maturity is unknown" do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
@@ -96,7 +96,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
expect(page).to have_content "Progress: Not enough data"
|
||||
end
|
||||
|
||||
it "should show that planting is in progress" do
|
||||
it "shows that planting is in progress" do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
@@ -114,7 +114,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
expect(page).not_to have_content "Not enough data"
|
||||
end
|
||||
|
||||
it "should show that planting is 100% complete (no date specified)" do
|
||||
it "shows that planting is 100% complete (no date specified)" do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
@@ -132,7 +132,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
expect(page).to have_content "Yes (no date specified)"
|
||||
end
|
||||
|
||||
it "should show that planting is 100% complete (date specified)" do
|
||||
it "shows that planting is 100% complete (date specified)" do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
@@ -240,7 +240,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
end
|
||||
|
||||
describe "Planting sunniness" do
|
||||
it "should show the a sunny image" do
|
||||
it "shows the a sunny image" do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
@@ -256,7 +256,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
expect(page).to have_css("img[alt='sun']")
|
||||
end
|
||||
|
||||
it "should show a sunniness not specified image" do
|
||||
it "shows a sunniness not specified image" do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
|
||||
@@ -3,6 +3,7 @@ require 'rails_helper'
|
||||
feature "signout" do
|
||||
let(:member) { create :member }
|
||||
|
||||
let(:path) {}
|
||||
scenario "redirect to previous page after signout" do
|
||||
visit crops_path # some random page
|
||||
click_link 'Sign in'
|
||||
@@ -29,8 +30,6 @@ feature "signout" do
|
||||
end
|
||||
end
|
||||
|
||||
let(:path) {}
|
||||
|
||||
describe 'after signout, redirect to signin page if page needs authentication' do
|
||||
include_examples "sign-in redirects", "/plantings/new"
|
||||
include_examples "sign-in redirects", "/harvests/new"
|
||||
|
||||
@@ -17,25 +17,25 @@ describe ApplicationHelper do
|
||||
|
||||
describe '#avatar_uri' do
|
||||
context 'with a normal user' do
|
||||
before :each do
|
||||
before do
|
||||
@member = FactoryBot.build(:member, email: 'example@example.com', preferred_avatar_uri: nil)
|
||||
end
|
||||
|
||||
it 'should render a gravatar uri' do
|
||||
it 'renders a gravatar uri' do
|
||||
expect(avatar_uri(@member)).to eq 'http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=150&default=identicon'
|
||||
end
|
||||
|
||||
it 'should render a gravatar uri for a given size' do
|
||||
it 'renders a gravatar uri for a given size' do
|
||||
expect(avatar_uri(@member, 456)).to eq 'http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=456&default=identicon'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a user who specified a preferred avatar uri' do
|
||||
before :each do
|
||||
before do
|
||||
@member = FactoryBot.build(:member, email: 'example@example.com', preferred_avatar_uri: 'http://media.catmoji.com/post/ujg/cat-in-hat.jpg')
|
||||
end
|
||||
|
||||
it 'should render a the specified uri' do
|
||||
it 'renders a the specified uri' do
|
||||
expect(avatar_uri(@member)).to eq 'http://media.catmoji.com/post/ujg/cat-in-hat.jpg'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ require 'rails_helper'
|
||||
# end
|
||||
# end
|
||||
RSpec.describe ButtonsHelper, type: :helper do
|
||||
before { allow(self).to receive(:can?) { true } }
|
||||
before { allow(self).to receive(:can?).and_return(true) }
|
||||
|
||||
let(:garden) { FactoryBot.create :garden }
|
||||
let(:planting) { FactoryBot.create :planting }
|
||||
|
||||
@@ -2,13 +2,13 @@ require 'rails_helper'
|
||||
|
||||
describe CropsHelper do
|
||||
describe "display_seed_availability" do
|
||||
before :each do
|
||||
@member = create :member
|
||||
before do
|
||||
@member = create :member
|
||||
@crop = create :tomato
|
||||
end
|
||||
|
||||
context "with no seeds" do
|
||||
it 'should render' do
|
||||
it 'renders' do
|
||||
expect(helper.display_seed_availability(@member, @crop)).to eq "You don't have any seeds of this crop."
|
||||
end
|
||||
end
|
||||
@@ -18,7 +18,7 @@ describe CropsHelper do
|
||||
create :seed, crop: @crop, quantity: nil, owner: @member
|
||||
end
|
||||
|
||||
it 'should render' do
|
||||
it 'renders' do
|
||||
expect(
|
||||
helper.display_seed_availability(@member, @crop)
|
||||
).to eq "You have an unknown quantity of seeds of this crop."
|
||||
@@ -35,7 +35,7 @@ describe CropsHelper do
|
||||
create :seed, crop: a_different_crop, quantity: 3, owner: @member
|
||||
end
|
||||
|
||||
it 'should render' do
|
||||
it 'renders' do
|
||||
expect(helper.display_seed_availability(@member, @crop)).to eq "You have 33 seeds of this crop."
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,12 +2,12 @@ require 'rails_helper'
|
||||
require './lib/actions/oauth_signup_action'
|
||||
|
||||
describe 'Growstuff::OauthSignupAction' do
|
||||
before :each do
|
||||
before do
|
||||
@action = Growstuff::OauthSignupAction.new
|
||||
end
|
||||
|
||||
context 'with a valid authentication' do
|
||||
before :each do
|
||||
before do
|
||||
@auth = OmniAuth::AuthHash.new('provider' => 'facebook',
|
||||
'uid' => '123545',
|
||||
'info' => {
|
||||
@@ -23,7 +23,7 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
end
|
||||
|
||||
context 'no existing user' do
|
||||
before :each do
|
||||
before do
|
||||
@auth['info']['email'] = 'no.existing.user@gmail.com'
|
||||
|
||||
Member.where(email: @auth['info']['email']).delete_all
|
||||
@@ -32,36 +32,36 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
@authentication = @action.establish_authentication(@auth, @member)
|
||||
end
|
||||
|
||||
after :each do
|
||||
after do
|
||||
@member.delete
|
||||
@authentication.delete
|
||||
end
|
||||
|
||||
it 'should create a new user' do
|
||||
it 'creates a new user' do
|
||||
expect(@action.member_created?).to eq true
|
||||
end
|
||||
|
||||
it 'should set the right email' do
|
||||
it 'sets the right email' do
|
||||
expect(@member.email).to eq @auth['info']['email']
|
||||
end
|
||||
|
||||
it 'should generate a login_name' do
|
||||
it 'generates a login_name' do
|
||||
expect(@member.login_name).to eq 'JohnnyB'
|
||||
end
|
||||
|
||||
it 'should set an avatar' do
|
||||
it 'sets an avatar' do
|
||||
expect(@member.preferred_avatar_uri).to eq @auth['info']['image']
|
||||
end
|
||||
|
||||
it 'should generate a random password' do
|
||||
it 'generates a random password' do
|
||||
expect(@member.password).not_to eq nil
|
||||
end
|
||||
|
||||
it 'should not agree to the tos' do
|
||||
it 'does not agree to the tos' do
|
||||
expect(@member.tos_agreement).to eq nil
|
||||
end
|
||||
|
||||
it 'should store the uid and provider for the member' do
|
||||
it 'stores the uid and provider for the member' do
|
||||
expect(@authentication.member.id).to eq @member.id
|
||||
expect(@authentication.provider).to eq 'facebook'
|
||||
expect(@authentication.uid).to eq '123545'
|
||||
@@ -70,7 +70,7 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
|
||||
context 'an existing user' do
|
||||
context 'who has never used oauth' do
|
||||
before :each do
|
||||
before do
|
||||
@auth['info']['email'] = 'never.used.oauth@yahoo.com'
|
||||
|
||||
Member.where(email: @auth['info']['email']).delete_all
|
||||
@@ -82,29 +82,29 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
@authentication = @action.establish_authentication(@auth, @member)
|
||||
end
|
||||
|
||||
after :each do
|
||||
after do
|
||||
@existing_member.delete
|
||||
@member.delete
|
||||
@authentication.delete
|
||||
end
|
||||
|
||||
it 'should not create a new user' do
|
||||
it 'does not create a new user' do
|
||||
expect(@action.member_created?).to eq nil
|
||||
end
|
||||
|
||||
it 'should locate the existing member by email' do
|
||||
it 'locates the existing member by email' do
|
||||
expect(@member.id).to eq @existing_member.id
|
||||
end
|
||||
|
||||
it 'should not generate a login_name' do
|
||||
it 'does not generate a login_name' do
|
||||
expect(@member.login_name).to eq 'existing'
|
||||
end
|
||||
|
||||
it 'should not change the avatar' do
|
||||
it 'does not change the avatar' do
|
||||
expect(@member.preferred_avatar_uri).to eq 'http://cl.jroo.me/z3/W/H/K/e/a.baa-very-cool-hat-you-.jpg'
|
||||
end
|
||||
|
||||
it 'should store the uid and provider for the member' do
|
||||
it 'stores the uid and provider for the member' do
|
||||
expect(@authentication.member.id).to eq @member.id
|
||||
expect(@authentication.provider).to eq 'facebook'
|
||||
expect(@authentication.uid).to eq '123545'
|
||||
@@ -112,7 +112,7 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
end
|
||||
|
||||
context 'who has used oauth' do
|
||||
before :each do
|
||||
before do
|
||||
@auth['info']['email'] = 'i.used.oauth.once@coolemail.com'
|
||||
|
||||
Member.where(email: @auth['info']['email']).delete_all
|
||||
@@ -131,30 +131,30 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
@authentication = @action.establish_authentication(@auth, @member)
|
||||
end
|
||||
|
||||
after :each do
|
||||
after do
|
||||
@existing_member.delete
|
||||
@member.delete
|
||||
@existing_authentication.delete
|
||||
@authentication.delete
|
||||
end
|
||||
|
||||
it 'should not create a new user' do
|
||||
it 'does not create a new user' do
|
||||
expect(@action.member_created?).to eq nil
|
||||
end
|
||||
|
||||
it 'should locate the existing member by uid and provider' do
|
||||
it 'locates the existing member by uid and provider' do
|
||||
expect(@member.id).to eq @existing_member.id
|
||||
end
|
||||
|
||||
it 'should not generate a login_name' do
|
||||
it 'does not generate a login_name' do
|
||||
expect(@member.login_name).to eq 'schrodingerscat'
|
||||
end
|
||||
|
||||
it 'should not change the avatar' do
|
||||
it 'does not change the avatar' do
|
||||
expect(@member.preferred_avatar_uri).to eq 'http://cl.jroo.me/z3/W/H/K/e/a.baa-very-cool-hat-you-.jpg'
|
||||
end
|
||||
|
||||
it 'should locate the existing uid and provider for the member' do
|
||||
it 'locates the existing uid and provider for the member' do
|
||||
expect(@authentication.id).to eq @existing_authentication.id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ describe Ability do
|
||||
context "crop wrangler" do
|
||||
let(:role) { FactoryBot.create(:crop_wrangler) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
member.roles << role
|
||||
end
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ require 'rails_helper'
|
||||
describe AlternateName do
|
||||
let(:an) { FactoryBot.create(:alternate_eggplant) }
|
||||
|
||||
it 'should save a basic alternate name' do
|
||||
it 'saves a basic alternate name' do
|
||||
expect(an.save).to be(true)
|
||||
end
|
||||
|
||||
it 'should be possible to add multiple alternate names to a crop' do
|
||||
it 'is possible to add multiple alternate names to a crop' do
|
||||
crop = an.crop
|
||||
an2 = AlternateName.create(
|
||||
name: "really alternative tomato",
|
||||
|
||||
@@ -42,7 +42,7 @@ describe Comment do
|
||||
end
|
||||
|
||||
context "ordering" do
|
||||
before(:each) do
|
||||
before do
|
||||
@m = FactoryBot.create(:member)
|
||||
@p = FactoryBot.create(:post, author: @m)
|
||||
@c1 = FactoryBot.create(:comment, post: @p, author: @m)
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Crop do
|
||||
let(:pp2) { FactoryBot.create(:plant_part) }
|
||||
let(:pp1) { FactoryBot.create(:plant_part) }
|
||||
let(:maize) { FactoryBot.create(:maize) }
|
||||
context 'all fields present' do
|
||||
let(:crop) { FactoryBot.create(:tomato) }
|
||||
|
||||
it 'should save a basic crop' do
|
||||
it 'saves a basic crop' do
|
||||
crop.save.should be(true)
|
||||
end
|
||||
|
||||
it 'should be fetchable from the database' do
|
||||
it 'is fetchable from the database' do
|
||||
crop.save
|
||||
@crop2 = Crop.find_by(name: 'tomato')
|
||||
@crop2.en_wikipedia_url.should eq("http://en.wikipedia.org/wiki/Tomato")
|
||||
@crop2.slug.should eq("tomato")
|
||||
end
|
||||
|
||||
it 'should stringify as the system name' do
|
||||
it 'stringifies as the system name' do
|
||||
crop.save
|
||||
crop.to_s.should eq('tomato')
|
||||
end
|
||||
@@ -27,7 +30,7 @@ describe Crop do
|
||||
end
|
||||
|
||||
context 'invalid data' do
|
||||
it 'should not save a crop without a system name' do
|
||||
it 'does not save a crop without a system name' do
|
||||
crop = FactoryBot.build(:crop, name: nil)
|
||||
expect { crop.save }.to raise_error ActiveRecord::StatementInvalid
|
||||
end
|
||||
@@ -139,12 +142,12 @@ describe Crop do
|
||||
end
|
||||
|
||||
context 'photos' do
|
||||
before :each do
|
||||
before do
|
||||
@crop = FactoryBot.create(:tomato)
|
||||
end
|
||||
|
||||
context 'with a planting photo' do
|
||||
before :each do
|
||||
before do
|
||||
@planting = FactoryBot.create(:planting, crop: @crop)
|
||||
@photo = FactoryBot.create(:photo, owner: @planting.owner)
|
||||
@planting.photos << @photo
|
||||
@@ -161,7 +164,7 @@ describe Crop do
|
||||
end
|
||||
|
||||
context 'with a harvest photo' do
|
||||
before :each do
|
||||
before do
|
||||
@harvest = FactoryBot.create(:harvest, crop: @crop)
|
||||
@photo = FactoryBot.create(:photo, owner: @harvest.owner)
|
||||
@harvest.photos << @photo
|
||||
@@ -173,13 +176,13 @@ describe Crop do
|
||||
end
|
||||
|
||||
context 'and planting photo' do
|
||||
before :each do
|
||||
before do
|
||||
@planting = FactoryBot.create(:planting, crop: @crop)
|
||||
@planting_photo = FactoryBot.create(:photo, owner: @planting.owner)
|
||||
@planting.photos << @planting_photo
|
||||
end
|
||||
|
||||
it 'should prefer the planting photo' do
|
||||
it 'prefers the planting photo' do
|
||||
expect(@crop.default_photo.id).to eq @planting_photo.id
|
||||
end
|
||||
end
|
||||
@@ -333,10 +336,6 @@ describe Crop do
|
||||
end
|
||||
end
|
||||
|
||||
let(:maize) { FactoryBot.create(:maize) }
|
||||
let(:pp1) { FactoryBot.create(:plant_part) }
|
||||
let(:pp2) { FactoryBot.create(:plant_part) }
|
||||
|
||||
context "harvests" do
|
||||
let(:h1) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) }
|
||||
let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) }
|
||||
@@ -386,7 +385,7 @@ describe Crop do
|
||||
end
|
||||
|
||||
context "csv loading" do
|
||||
before(:each) do
|
||||
before do
|
||||
# don't use 'let' for this -- we need to actually create it,
|
||||
# regardless of whether it's used.
|
||||
@cropbot = FactoryBot.create(:cropbot)
|
||||
@@ -553,11 +552,11 @@ describe Crop do
|
||||
tomato.destroy
|
||||
end
|
||||
|
||||
it "should delete the association between post and the crop(tomato)" do
|
||||
it "deletes the association between post and the crop(tomato)" do
|
||||
expect(Post.find(post.id).crops).to eq [maize]
|
||||
end
|
||||
|
||||
it "should not delete the posts" do
|
||||
it "does not delete the posts" do
|
||||
expect(Post.find(post.id)).not_to eq nil
|
||||
end
|
||||
end
|
||||
@@ -577,11 +576,11 @@ describe Crop do
|
||||
end
|
||||
|
||||
describe "rejecting a crop" do
|
||||
it "should give reason if a default option" do
|
||||
it "gives reason if a default option" do
|
||||
expect(rejected_reason.rejection_explanation).to eq "not edible"
|
||||
end
|
||||
|
||||
it "should show rejection notes if reason was other" do
|
||||
it "shows rejection notes if reason was other" do
|
||||
expect(rejected_other.rejection_explanation).to eq "blah blah blah"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Follow do
|
||||
before(:each) do
|
||||
before do
|
||||
@member1 = FactoryBot.create(:member)
|
||||
@member2 = FactoryBot.create(:member)
|
||||
end
|
||||
@@ -20,20 +20,20 @@ describe Follow do
|
||||
end
|
||||
|
||||
context "when follow is created" do
|
||||
before(:each) do
|
||||
before do
|
||||
@follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id)
|
||||
end
|
||||
|
||||
it "should not duplicate follows" do
|
||||
it "does not duplicate follows" do
|
||||
expect(Follow.create(follower_id: @member1.id, followed_id: @member2.id)).not_to be_valid
|
||||
end
|
||||
|
||||
it "should list users in following/follower collections when follow is created" do
|
||||
it "lists users in following/follower collections when follow is created" do
|
||||
expect(@member1.followed).to include(@member2)
|
||||
expect(@member2.followers).to include(@member1)
|
||||
end
|
||||
|
||||
it "should no longer list users in following/follower collections when follow is deleted" do
|
||||
it "noes longer list users in following/follower collections when follow is deleted" do
|
||||
@follow.destroy
|
||||
expect(@member1.followed).not_to include(@member2)
|
||||
expect(@member2.followers).not_to include(@member1)
|
||||
|
||||
@@ -4,11 +4,11 @@ describe Garden do
|
||||
let(:owner) { FactoryBot.create(:member, login_name: 'hatupatu') }
|
||||
let(:garden) { FactoryBot.create(:garden, owner: owner, name: 'Springfield Community Garden') }
|
||||
|
||||
it "should have a slug" do
|
||||
it "has a slug" do
|
||||
garden.slug.should match(/hatupatu-springfield-community-garden/)
|
||||
end
|
||||
|
||||
it "should have a description" do
|
||||
it "has a description" do
|
||||
garden.description.should == "This is a **totally** cool garden"
|
||||
end
|
||||
|
||||
@@ -47,11 +47,11 @@ describe Garden do
|
||||
garden.should_not be_valid
|
||||
end
|
||||
|
||||
it "should have an owner" do
|
||||
it "has an owner" do
|
||||
garden.owner.should be_an_instance_of Member
|
||||
end
|
||||
|
||||
it "should stringify as its name" do
|
||||
it "stringifies as its name" do
|
||||
garden.to_s.should == garden.name
|
||||
end
|
||||
|
||||
@@ -63,14 +63,14 @@ describe Garden do
|
||||
let(:pear) { FactoryBot.create(:pear) }
|
||||
let(:walnut) { FactoryBot.create(:walnut) }
|
||||
|
||||
it "should fetch < 4 featured plantings if insufficient exist" do
|
||||
it "fetches < 4 featured plantings if insufficient exist" do
|
||||
@p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner)
|
||||
@p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner)
|
||||
|
||||
expect(garden.featured_plantings).to eq [@p2, @p1]
|
||||
end
|
||||
|
||||
it "should fetch most recent 4 featured plantings" do
|
||||
it "fetches most recent 4 featured plantings" do
|
||||
@p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner)
|
||||
@p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner)
|
||||
@p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner)
|
||||
@@ -80,7 +80,7 @@ describe Garden do
|
||||
expect(garden.featured_plantings).to eq [@p5, @p4, @p3, @p2]
|
||||
end
|
||||
|
||||
it "should skip repeated plantings" do
|
||||
it "skips repeated plantings" do
|
||||
@p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner)
|
||||
@p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner)
|
||||
@p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner)
|
||||
@@ -148,7 +148,7 @@ describe Garden do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should refuse invalid unit values' do
|
||||
it 'refuses invalid unit values' do
|
||||
garden = FactoryBot.build(:garden, area_unit: 'not valid')
|
||||
garden.should_not be_valid
|
||||
garden.errors[:area_unit].should include("not valid is not a valid area unit")
|
||||
|
||||
@@ -52,7 +52,7 @@ describe Harvest do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should refuse invalid unit values' do
|
||||
it 'refuses invalid unit values' do
|
||||
@harvest = FactoryBot.build(:harvest, unit: 'not valid')
|
||||
@harvest.should_not be_valid
|
||||
@harvest.errors[:unit].should include("not valid is not a valid unit")
|
||||
@@ -105,7 +105,7 @@ describe Harvest do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should refuse invalid weight unit values' do
|
||||
it 'refuses invalid weight unit values' do
|
||||
@harvest = FactoryBot.build(:harvest, weight_unit: 'not valid')
|
||||
@harvest.should_not be_valid
|
||||
@harvest.errors[:weight_unit].should include("not valid is not a valid unit")
|
||||
@@ -223,23 +223,23 @@ describe Harvest do
|
||||
end
|
||||
|
||||
context 'photos' do
|
||||
before :each do
|
||||
before do
|
||||
@harvest = FactoryBot.create(:harvest)
|
||||
end
|
||||
|
||||
context 'without a photo' do
|
||||
it 'should have no default photo' do
|
||||
it 'has no default photo' do
|
||||
expect(@harvest.default_photo).to eq nil
|
||||
end
|
||||
|
||||
context 'and with a crop(planting) photo' do
|
||||
before :each do
|
||||
before do
|
||||
@planting = FactoryBot.create(:planting, crop: @harvest.crop)
|
||||
@photo = FactoryBot.create(:photo, owner: @planting.owner)
|
||||
@planting.photos << @photo
|
||||
end
|
||||
|
||||
it 'should have a default photo' do
|
||||
it 'has a default photo' do
|
||||
expect(@harvest.default_photo).to eq @photo
|
||||
end
|
||||
end
|
||||
@@ -270,19 +270,19 @@ describe Harvest do
|
||||
end
|
||||
|
||||
context 'and with a crop(planting) photo' do
|
||||
before :each do
|
||||
before do
|
||||
@planting = FactoryBot.create(:planting, crop: @harvest.crop)
|
||||
@crop_photo = FactoryBot.create(:photo, owner: @planting.owner)
|
||||
@planting.photos << @crop_photo
|
||||
end
|
||||
|
||||
it 'should prefer the harvest photo' do
|
||||
it 'prefers the harvest photo' do
|
||||
expect(@harvest.default_photo).to eq @photo
|
||||
end
|
||||
end
|
||||
|
||||
context 'and a second photo' do
|
||||
before :each do
|
||||
before do
|
||||
@photo2 = FactoryBot.create(:photo, owner: @harvest.owner)
|
||||
@harvest.photos << @photo2
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ describe 'like' do
|
||||
let(:post) { FactoryBot.create(:post) }
|
||||
|
||||
context 'existing like' do
|
||||
before(:each) do
|
||||
before do
|
||||
@like = Like.create(member: member, likeable: post)
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ describe 'member' do
|
||||
expect(member.bio).to eq 'I love seeds'
|
||||
end
|
||||
|
||||
it 'should have a default garden' do
|
||||
it 'has a default garden' do
|
||||
expect(member.gardens.count).to eq 1
|
||||
end
|
||||
|
||||
@@ -28,16 +28,16 @@ describe 'member' do
|
||||
expect(member.show_email).to eq false
|
||||
end
|
||||
|
||||
it 'should stringify as the login_name' do
|
||||
it 'stringifies as the login_name' do
|
||||
expect(member.to_s).to eq 'hinemoa'
|
||||
end
|
||||
|
||||
it 'should be able to fetch posts' do
|
||||
it 'is able to fetch posts' do
|
||||
post = FactoryBot.create(:post, author: member)
|
||||
expect(member.posts).to eq [post]
|
||||
end
|
||||
|
||||
it 'should be able to fetch gardens' do
|
||||
it 'is able to fetch gardens' do
|
||||
expect(member.gardens.first.name).to eq "Garden"
|
||||
end
|
||||
|
||||
@@ -93,7 +93,7 @@ describe 'member' do
|
||||
context 'no TOS agreement' do
|
||||
let(:member) { FactoryBot.build(:no_tos_member) }
|
||||
|
||||
it "should refuse to save a member who hasn't agreed to the TOS" do
|
||||
it "refuses to save a member who hasn't agreed to the TOS" do
|
||||
member.save.should_not be(true)
|
||||
end
|
||||
end
|
||||
@@ -108,7 +108,7 @@ describe 'member' do
|
||||
end
|
||||
|
||||
context 'same :login_name' do
|
||||
it "should not allow two members with the same login_name" do
|
||||
it "does not allow two members with the same login_name" do
|
||||
FactoryBot.create(:member, login_name: "bob")
|
||||
member = FactoryBot.build(:member, login_name: "bob")
|
||||
member.should_not be_valid
|
||||
@@ -200,7 +200,7 @@ describe 'member' do
|
||||
end
|
||||
|
||||
context 'confirmed scope' do
|
||||
before(:each) do
|
||||
before do
|
||||
FactoryBot.create(:member)
|
||||
FactoryBot.create(:member)
|
||||
end
|
||||
@@ -252,7 +252,7 @@ describe 'member' do
|
||||
# 4) ordered by the most recent sign in
|
||||
|
||||
context 'with a few members and plantings' do
|
||||
before :each do
|
||||
before do
|
||||
@members = [
|
||||
:london_member, :london_member, :london_member,
|
||||
:unconfirmed_member, # !1
|
||||
|
||||
@@ -218,25 +218,25 @@ describe Planting do
|
||||
planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}"
|
||||
end
|
||||
|
||||
it "should have a slug" do
|
||||
it "has a slug" do
|
||||
planting.slug.should match(/^hatupatu-springfield-community-garden-tomato$/)
|
||||
end
|
||||
|
||||
it 'should sort in reverse creation order' do
|
||||
it 'sorts in reverse creation order' do
|
||||
@planting2 = FactoryBot.create(:planting)
|
||||
Planting.first.should eq @planting2
|
||||
end
|
||||
|
||||
describe '#planted?' do
|
||||
it "should be false for future plantings" do
|
||||
it "is false for future plantings" do
|
||||
planting = FactoryBot.create :planting, planted_at: Time.zone.today + 1
|
||||
expect(planting.planted?).to eq(false)
|
||||
end
|
||||
it "should be false for never planted" do
|
||||
it "is false for never planted" do
|
||||
planting = FactoryBot.create :planting, planted_at: nil
|
||||
expect(planting.planted?).to eq(false)
|
||||
end
|
||||
it "should be true for past plantings" do
|
||||
it "is true for past plantings" do
|
||||
planting = FactoryBot.create :planting, planted_at: Time.zone.today - 1
|
||||
expect(planting.planted?).to eq(true)
|
||||
end
|
||||
@@ -287,7 +287,7 @@ describe Planting do
|
||||
context 'sunniness' do
|
||||
let(:planting) { FactoryBot.create(:sunny_planting) }
|
||||
|
||||
it 'should have a sunniness value' do
|
||||
it 'has a sunniness value' do
|
||||
planting.sunniness.should eq 'sun'
|
||||
end
|
||||
|
||||
@@ -298,7 +298,7 @@ describe Planting do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should refuse invalid sunniness values' do
|
||||
it 'refuses invalid sunniness values' do
|
||||
@planting = FactoryBot.build(:planting, sunniness: 'not valid')
|
||||
@planting.should_not be_valid
|
||||
@planting.errors[:sunniness].should include("not valid is not a valid sunniness value")
|
||||
@@ -306,7 +306,7 @@ describe Planting do
|
||||
end
|
||||
|
||||
context 'planted from' do
|
||||
it 'should have a planted_from value' do
|
||||
it 'has a planted_from value' do
|
||||
@planting = FactoryBot.create(:seed_planting)
|
||||
@planting.planted_from.should eq 'seed'
|
||||
end
|
||||
@@ -320,7 +320,7 @@ describe Planting do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should refuse invalid planted_from values' do
|
||||
it 'refuses invalid planted_from values' do
|
||||
@planting = FactoryBot.build(:planting, planted_from: 'not valid')
|
||||
@planting.should_not be_valid
|
||||
@planting.errors[:planted_from].should include("not valid is not a valid planting method")
|
||||
|
||||
@@ -5,7 +5,7 @@ describe Post do
|
||||
|
||||
it_behaves_like "it is likeable"
|
||||
|
||||
it "should have a slug" do
|
||||
it "has a slug" do
|
||||
post = FactoryBot.create(:post, author: member)
|
||||
time = post.created_at
|
||||
datestr = time.strftime("%Y%m%d")
|
||||
@@ -136,16 +136,16 @@ describe Post do
|
||||
let!(:chard) { FactoryBot.create(:chard) }
|
||||
let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") }
|
||||
|
||||
it "should be generated" do
|
||||
it "is generated" do
|
||||
expect(tomato.posts).to eq [post]
|
||||
expect(maize.posts).to eq [post]
|
||||
end
|
||||
|
||||
it "should not duplicate" do
|
||||
it "does not duplicate" do
|
||||
expect(post.crops) =~ [tomato, maize]
|
||||
end
|
||||
|
||||
it "should be updated when post was modified" do
|
||||
it "is updated when post was modified" do
|
||||
post.update(body: "[chard](crop)")
|
||||
|
||||
expect(post.crops).to eq [chard]
|
||||
@@ -159,12 +159,12 @@ describe Post do
|
||||
post.destroy
|
||||
end
|
||||
|
||||
it "should delete the association" do
|
||||
it "deletes the association" do
|
||||
expect(Crop.find(tomato.id).posts).to eq []
|
||||
expect(Crop.find(maize.id).posts).to eq []
|
||||
end
|
||||
|
||||
it "should not delete the crops" do
|
||||
it "does not delete the crops" do
|
||||
expect(Crop.find(tomato.id)).not_to eq nil
|
||||
expect(Crop.find(maize.id)).not_to eq nil
|
||||
end
|
||||
|
||||
@@ -4,11 +4,11 @@ describe ScientificName do
|
||||
context 'all fields present' do
|
||||
let(:sn) { FactoryBot.create(:zea_mays) }
|
||||
|
||||
it 'should save a basic scientific name' do
|
||||
it 'saves a basic scientific name' do
|
||||
sn.save.should be(true)
|
||||
end
|
||||
|
||||
it 'should be fetchable from the database' do
|
||||
it 'is fetchable from the database' do
|
||||
sn.save
|
||||
@sn2 = ScientificName.find_by(name: 'Zea mays')
|
||||
@sn2.crop.name.should == 'maize'
|
||||
@@ -21,7 +21,7 @@ describe ScientificName do
|
||||
end
|
||||
|
||||
context 'invalid data' do
|
||||
it 'should not save a scientific name without a name' do
|
||||
it 'does not save a scientific name without a name' do
|
||||
sn = ScientificName.new
|
||||
expect { sn.save! }.to raise_error ActiveRecord::RecordInvalid
|
||||
end
|
||||
|
||||
@@ -4,11 +4,11 @@ describe Seed do
|
||||
let(:owner) { FactoryBot.create :owner, login_name: 'tamateapokaiwhenua' }
|
||||
let(:seed) { FactoryBot.build(:seed, owner: owner) }
|
||||
|
||||
it 'should save a basic seed' do
|
||||
it 'saves a basic seed' do
|
||||
seed.save.should be(true)
|
||||
end
|
||||
|
||||
it "should have a slug" do
|
||||
it "has a slug" do
|
||||
seed.save
|
||||
seed.slug.should match(/tamateapokaiwhenua-magic-bean/)
|
||||
end
|
||||
@@ -45,7 +45,7 @@ describe Seed do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should refuse invalid tradable_to values' do
|
||||
it 'refuses invalid tradable_to values' do
|
||||
@seed = FactoryBot.build(:seed, tradable_to: 'not valid')
|
||||
@seed.should_not be_valid
|
||||
@seed.errors[:tradable_to].should include(
|
||||
@@ -54,7 +54,7 @@ describe Seed do
|
||||
)
|
||||
end
|
||||
|
||||
it 'should not allow nil or blank values' do
|
||||
it 'does not allow nil or blank values' do
|
||||
@seed = FactoryBot.build(:seed, tradable_to: nil)
|
||||
@seed.should_not be_valid
|
||||
@seed = FactoryBot.build(:seed, tradable_to: '')
|
||||
@@ -112,7 +112,7 @@ describe Seed do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should refuse invalid organic/GMO/heirloom values' do
|
||||
it 'refuses invalid organic/GMO/heirloom values' do
|
||||
%i(organic gmo heirloom).each do |field|
|
||||
@seed = FactoryBot.build(:seed, field => 'not valid')
|
||||
@seed.should_not be_valid
|
||||
@@ -120,7 +120,7 @@ describe Seed do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not allow nil or blank values' do
|
||||
it 'does not allow nil or blank values' do
|
||||
%i(organic gmo heirloom).each do |field|
|
||||
@seed = FactoryBot.build(:seed, field => nil)
|
||||
@seed.should_not be_valid
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
module ControllerMacros
|
||||
def login_member(member_factory = :member)
|
||||
let(:member) { FactoryBot.create(member_factory || :member) }
|
||||
before(:each) do
|
||||
before do
|
||||
@request.env["devise.mapping"] = Devise.mappings[:member]
|
||||
sign_in member
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ RSpec.configure do |config|
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
config.before do
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
|
||||
@@ -11,11 +11,11 @@ RSpec.configure do |config|
|
||||
DatabaseCleaner.strategy = :truncation
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
config.before do
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
|
||||
config.after(:each) do
|
||||
config.after do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
shared_examples "it is likeable" do
|
||||
before(:each) do
|
||||
before do
|
||||
# Possibly a horrible hack.
|
||||
# Will fail if factory name does not match the model name..
|
||||
@likeable = FactoryBot.create(described_class.to_s.underscore.to_sym)
|
||||
@@ -17,7 +17,7 @@ shared_examples "it is likeable" do
|
||||
expect(@likeable.members.length).to eq 2
|
||||
end
|
||||
|
||||
it 'should destroy the like when it is destroyed' do
|
||||
it 'destroys the like when it is destroyed' do
|
||||
like_count = -1 * @likeable.likes.count
|
||||
expect { @likeable.destroy }.to change(Like, :count).by like_count
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'admin/index.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:admin_member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'admin/newsletter.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:admin_member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/edit" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
assign(:comment, FactoryBot.create(:comment))
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
page = 1
|
||||
per_page = 2
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'comments/index.rss.haml' do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@author = FactoryBot.create(:member)
|
||||
@post = FactoryBot.create(:post)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@post = FactoryBot.create(:post)
|
||||
@comment = FactoryBot.create(:comment, post: @post)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/show" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@comment = assign(:comment, FactoryBot.create(:comment))
|
||||
render
|
||||
|
||||
@@ -5,7 +5,7 @@ describe "crops/_planting_advice" do
|
||||
|
||||
let(:planting) { FactoryBot.create(:planting) }
|
||||
|
||||
shared_examples "render planting_advice" do
|
||||
shared_context "render planting_advice" do
|
||||
before { render 'crops/planting_advice', crop: planting.crop }
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/_popover" do
|
||||
before(:each) do
|
||||
before do
|
||||
@tomato = FactoryBot.create(:tomato)
|
||||
@sn = FactoryBot.create(:solanum_lycopersicum, crop: @tomato)
|
||||
@planting = FactoryBot.create(:planting, crop: @tomato)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/edit" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) do
|
||||
FactoryBot.create(:crop_wrangling_member)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/hierarchy" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@tomato = FactoryBot.create(:tomato)
|
||||
@roma = FactoryBot.create(:crop, name: 'Roma tomato', parent: @tomato)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
page = 1
|
||||
per_page = 2
|
||||
@@ -29,7 +29,7 @@ describe "crops/index" do
|
||||
end
|
||||
|
||||
context "logged in and crop wrangler" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:crop_wrangling_member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'crops/index.rss.haml' do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@author = FactoryBot.create(:member)
|
||||
@tomato = FactoryBot.create(:tomato)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
@crop = FactoryBot.create(:maize)
|
||||
3.times do
|
||||
@crop.scientific_names.build
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/wrangle" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:crop_wrangling_member)
|
||||
controller.stub(:current_user) { @member }
|
||||
page = 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
describe 'devise/confirmations/new.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
@view.stub(:resource).and_return(Member.new)
|
||||
@view.stub(:resource_name).and_return("member")
|
||||
@view.stub(:resource_class).and_return(Member)
|
||||
@@ -7,7 +7,7 @@ describe 'devise/confirmations/new.html.haml', type: "view" do
|
||||
render
|
||||
end
|
||||
|
||||
it 'should contain a login field' do
|
||||
it 'contains a login field' do
|
||||
rendered.should have_content "Enter either your login name or your email address"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,16 +2,16 @@ require 'rails_helper'
|
||||
|
||||
describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@resource = FactoryBot.create(:member)
|
||||
render
|
||||
end
|
||||
|
||||
it 'should have a confirmation link' do
|
||||
it 'has a confirmation link' do
|
||||
rendered.should have_content 'Confirm my account'
|
||||
end
|
||||
|
||||
it 'should have a link to the homepage' do
|
||||
it 'has a link to the homepage' do
|
||||
rendered.should have_content root_url
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,14 +2,14 @@ require 'rails_helper'
|
||||
|
||||
describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@resource = mock_model(Member)
|
||||
@resource.stub(:email).and_return("example@example.com")
|
||||
@resource.stub(:reset_password_token).and_return("joe")
|
||||
render
|
||||
end
|
||||
|
||||
it 'should have some of the right text' do
|
||||
it 'has some of the right text' do
|
||||
rendered.should have_content 'Change my password'
|
||||
rendered.should have_content 'Someone has requested a link to reset your password'
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
require 'rails_helper'
|
||||
describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@resource = FactoryBot.create(:member)
|
||||
render
|
||||
end
|
||||
|
||||
it "should explain what's happened" do
|
||||
it "explains what's happened" do
|
||||
rendered.should have_content "account has been locked"
|
||||
end
|
||||
|
||||
it "should have an unlock link" do
|
||||
it "has an unlock link" do
|
||||
rendered.should have_content "Unlock my account"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe 'devise/registrations/edit.html.haml', type: "view" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@member = FactoryBot.create(:member)
|
||||
controller.stub(:current_member) { @member }
|
||||
@@ -12,13 +12,13 @@ describe 'devise/registrations/edit.html.haml', type: "view" do
|
||||
@view.stub(:devise_mapping).and_return(Devise.mappings[:member])
|
||||
end
|
||||
|
||||
it 'should have some fields' do
|
||||
it 'has some fields' do
|
||||
render
|
||||
rendered.should have_content 'Email'
|
||||
end
|
||||
|
||||
context 'email section' do
|
||||
before(:each) do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ describe 'devise/registrations/edit.html.haml', type: "view" do
|
||||
end
|
||||
|
||||
context 'profile section' do
|
||||
before(:each) do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
@@ -66,7 +66,7 @@ describe 'devise/registrations/edit.html.haml', type: "view" do
|
||||
end
|
||||
|
||||
context 'connected to twitter' do
|
||||
before(:each) do
|
||||
before do
|
||||
@twitter_auth = FactoryBot.create(:authentication, member: @member)
|
||||
render
|
||||
end
|
||||
@@ -88,7 +88,7 @@ describe 'devise/registrations/edit.html.haml', type: "view" do
|
||||
end
|
||||
|
||||
context 'connected to flickr' do
|
||||
before(:each) do
|
||||
before do
|
||||
@flickr_auth = FactoryBot.create(:flickr_authentication, member: @member)
|
||||
render
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe 'devise/registrations/new.html.haml', type: "view" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@view.stub(:resource).and_return(Member.new)
|
||||
@view.stub(:resource_name).and_return("member")
|
||||
@view.stub(:resource_class).and_return(Member)
|
||||
@@ -10,7 +10,7 @@ describe 'devise/registrations/new.html.haml', type: "view" do
|
||||
render
|
||||
end
|
||||
|
||||
it 'should have some fields' do
|
||||
it 'has some fields' do
|
||||
rendered.should have_content 'Email'
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe 'devise/sessions/new.html.haml', type: "view" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@view.stub(:resource).and_return(Member.new)
|
||||
@view.stub(:resource_name).and_return("member")
|
||||
@view.stub(:resource_class).and_return(Member)
|
||||
@@ -10,7 +10,7 @@ describe 'devise/sessions/new.html.haml', type: "view" do
|
||||
render
|
||||
end
|
||||
|
||||
it 'should have some fields' do
|
||||
it 'has some fields' do
|
||||
rendered.should have_content 'Remember me'
|
||||
rendered.should have_content 'Password'
|
||||
end
|
||||
|
||||
@@ -9,14 +9,14 @@ describe 'devise/shared/_links.haml', type: "view" do
|
||||
dm
|
||||
end
|
||||
|
||||
it 'should have a sign-in link if not in sessions' do
|
||||
it 'has a sign-in link if not in sessions' do
|
||||
@view.stub(:controller_name).and_return("anything but sessions")
|
||||
@view.stub(:resource_name).and_return("member")
|
||||
@view.stub(devise_mapping: devise_mapping(false, false, false, false, false))
|
||||
render
|
||||
end
|
||||
|
||||
it "shouldn't have a sign-in link if in sessions" do
|
||||
it "does not have a sign-in link if in sessions" do
|
||||
@view.stub(:controller_name).and_return("sessions")
|
||||
@view.stub(:resource_name).and_return("member")
|
||||
@view.stub(devise_mapping: devise_mapping(false, false, false, false, false))
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe 'devise/unlocks/new.html.haml', type: "view" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@view.stub(:resource).and_return(Member.new)
|
||||
@view.stub(:resource_name).and_return("member")
|
||||
@view.stub(:resource_class).and_return(Member)
|
||||
@@ -10,7 +10,7 @@ describe 'devise/unlocks/new.html.haml', type: "view" do
|
||||
render
|
||||
end
|
||||
|
||||
it 'should have some fields' do
|
||||
it 'has some fields' do
|
||||
rendered.should have_content 'Email'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "forums/edit" do
|
||||
before(:each) do
|
||||
before do
|
||||
@forum = assign(:forum, stub_model(Forum,
|
||||
name: "MyString",
|
||||
description: "MyText",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "forums/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
@admin = FactoryBot.create(:admin_member)
|
||||
controller.stub(:current_user) { @admin }
|
||||
@forum1 = FactoryBot.create(:forum)
|
||||
@@ -20,7 +20,7 @@ describe "forums/index" do
|
||||
end
|
||||
|
||||
context "posts" do
|
||||
before(:each) do
|
||||
before do
|
||||
@post = FactoryBot.create(:forum_post, forum: @forum1)
|
||||
@comment = FactoryBot.create(:comment, post: @post)
|
||||
render
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "forums/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
@forum = assign(:forum, FactoryBot.create(:forum))
|
||||
render
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "forums/show" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@forum = assign(:forum, FactoryBot.create(:forum))
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe "gardens/edit" do
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@owner = FactoryBot.create(:member)
|
||||
sign_in @owner
|
||||
controller.stub(:current_user) { @owner }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "gardens/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "gardens/show" do
|
||||
before(:each) do
|
||||
before do
|
||||
@owner = FactoryBot.create(:member)
|
||||
controller.stub(:current_user) { @owner }
|
||||
@garden = FactoryBot.create(:garden, owner: @owner)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "harvests/edit" do
|
||||
before(:each) do
|
||||
before do
|
||||
assign(:harvest, FactoryBot.create(:harvest))
|
||||
render
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "harvests/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@member = FactoryBot.create(:member)
|
||||
@tomato = FactoryBot.create(:tomato)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'harvests/index.rss.haml' do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@member = FactoryBot.create(:member)
|
||||
@tomato = FactoryBot.create(:tomato)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "harvests/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
assign(:harvest, FactoryBot.create(:harvest))
|
||||
render
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe 'home/_blurb.html.haml', type: "view" do
|
||||
context 'signed out' do
|
||||
before :each do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
render
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'home/_members.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:london_member)
|
||||
@member.updated_at = 2.days.ago
|
||||
assign(:members, [@member])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'home/_seeds.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
@owner = FactoryBot.create(:london_member)
|
||||
@seed = FactoryBot.create(:tradable_seed, owner: @owner)
|
||||
render
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'home/index.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:london_member)
|
||||
@member.updated_at = 2.days.ago
|
||||
assign(:interesting_members, [@member])
|
||||
@@ -19,7 +19,7 @@ describe 'home/index.html.haml', type: "view" do
|
||||
end
|
||||
|
||||
context 'logged out' do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
render
|
||||
end
|
||||
@@ -31,7 +31,7 @@ describe 'home/index.html.haml', type: "view" do
|
||||
end
|
||||
|
||||
context 'signed in' do
|
||||
before(:each) do
|
||||
before do
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
render
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe 'layouts/_header.html.haml', type: "view" do
|
||||
context "when not logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
render
|
||||
end
|
||||
@@ -11,7 +11,7 @@ describe 'layouts/_header.html.haml', type: "view" do
|
||||
assert_select("a.navbar-brand img[src]", href: root_path)
|
||||
end
|
||||
|
||||
it 'should have signup/signin links' do
|
||||
it 'has signup/signin links' do
|
||||
rendered.should have_content 'Sign up'
|
||||
rendered.should have_content 'Sign in'
|
||||
end
|
||||
@@ -51,7 +51,7 @@ describe 'layouts/_header.html.haml', type: "view" do
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
@@ -59,34 +59,34 @@ describe 'layouts/_header.html.haml', type: "view" do
|
||||
end
|
||||
|
||||
context "login name" do
|
||||
it 'should have member login name' do
|
||||
it 'has member login name' do
|
||||
rendered.should have_content @member.login_name.to_s
|
||||
end
|
||||
it "should show link to member's gardens" do
|
||||
it "shows link to member's gardens" do
|
||||
assert_select("a[href='#{member_gardens_path(@member)}']", "Gardens")
|
||||
end
|
||||
it "should show link to member's plantings" do
|
||||
it "shows link to member's plantings" do
|
||||
assert_select("a[href='#{member_plantings_path(@member)}']", "Plantings")
|
||||
end
|
||||
it "should show link to member's seeds" do
|
||||
it "shows link to member's seeds" do
|
||||
assert_select("a[href='#{member_seeds_path(@member)}']", "Seeds")
|
||||
end
|
||||
it "should show link to member's posts" do
|
||||
it "shows link to member's posts" do
|
||||
assert_select("a[href='#{member_posts_path(@member)}']", "Posts")
|
||||
end
|
||||
end
|
||||
|
||||
it 'should show signout link' do
|
||||
it 'shows signout link' do
|
||||
rendered.should have_content 'Sign out'
|
||||
end
|
||||
|
||||
it 'should show inbox link' do
|
||||
it 'shows inbox link' do
|
||||
rendered.should have_content 'Inbox'
|
||||
rendered.should_not match(/Inbox \(\d+\)/)
|
||||
end
|
||||
|
||||
context 'has notifications' do
|
||||
it 'should show inbox count' do
|
||||
it 'shows inbox count' do
|
||||
FactoryBot.create(:notification, recipient: @member)
|
||||
render
|
||||
rendered.should have_content 'Inbox (1)'
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'layouts/_meta.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it 'should have a Posts RSS feed' do
|
||||
it 'has a Posts RSS feed' do
|
||||
posts_rss = url_for(controller: 'posts', format: 'rss', only_path: false)
|
||||
assert_select "head>link[href='#{posts_rss}']"
|
||||
end
|
||||
|
||||
it 'should have a Crops RSS feed' do
|
||||
it 'has a Crops RSS feed' do
|
||||
crops_rss = url_for(controller: 'crops', format: 'rss', only_path: false)
|
||||
assert_select "head>link[href='#{crops_rss}']"
|
||||
end
|
||||
|
||||
it 'should have a Plantings RSS feed' do
|
||||
it 'has a Plantings RSS feed' do
|
||||
plantings_rss = url_for(controller: 'plantings', format: 'rss', only_path: false)
|
||||
assert_select "head>link[href='#{plantings_rss}']"
|
||||
end
|
||||
|
||||
it 'should have a title' do
|
||||
it 'has a title' do
|
||||
assert_select "head>title"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'layouts/application.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ describe "members/_location" do
|
||||
context "member with location" do
|
||||
let(:member) { FactoryBot.create(:london_member) }
|
||||
|
||||
before(:each) { render partial: 'members/location', locals: { member: member } }
|
||||
before { render partial: 'members/location', locals: { member: member } }
|
||||
|
||||
it 'shows location if available' do
|
||||
expect(rendered).to have_content member.location
|
||||
@@ -16,7 +16,7 @@ describe "members/_location" do
|
||||
end
|
||||
|
||||
context "member with no location" do
|
||||
before(:each) do
|
||||
before do
|
||||
member = FactoryBot.create(:member)
|
||||
render partial: 'members/location', locals: { member: member }
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'rails_helper'
|
||||
describe "members/index" do
|
||||
let(:member) { FactoryBot.create(:london_member) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
page = 1
|
||||
per_page = 2
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'rails_helper'
|
||||
describe 'members/show.rss.haml', type: "view" do
|
||||
subject { rendered }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
@member = assign(:member, FactoryBot.create(:member, login_name: 'callum'))
|
||||
@post1 = FactoryBot.create(:post, id: 1, author: @member)
|
||||
@post2 = FactoryBot.create(:markdown_post, id: 2, author: @member)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "notifications/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
controller.stub(:current_user) { @member }
|
||||
end
|
||||
|
||||
context "ordinary notifications" do
|
||||
before(:each) do
|
||||
before do
|
||||
@notification = FactoryBot.create(:notification, sender: @member,
|
||||
recipient: @member)
|
||||
assign(:notifications, Kaminari.paginate_array([@notification, @notification]).page(1))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "notifications/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
@recipient = FactoryBot.create(:member)
|
||||
@sender = FactoryBot.create(:member)
|
||||
assign(:notification, FactoryBot.create(:notification, recipient_id: @recipient.id, sender_id: @sender.id))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "notifications/show" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
@notification = FactoryBot.create(:notification, recipient: @member)
|
||||
assign(:notification, @notification)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'notifier/notify.html.haml', type: "view" do
|
||||
before(:each) do
|
||||
before do
|
||||
@notification = FactoryBot.create(:notification)
|
||||
@reply_link = "http://example.com"
|
||||
@signed_message = "EncryptedMessage"
|
||||
@@ -9,24 +9,24 @@ describe 'notifier/notify.html.haml', type: "view" do
|
||||
render
|
||||
end
|
||||
|
||||
it 'should say that you have a message' do
|
||||
it 'says that you have a message' do
|
||||
rendered.should have_content 'You have received a message'
|
||||
end
|
||||
|
||||
it 'should include notification metadata' do
|
||||
it 'includes notification metadata' do
|
||||
rendered.should have_content @notification.sender.login_name
|
||||
rendered.should have_content @notification.post.subject
|
||||
end
|
||||
|
||||
it 'should include a reply link' do
|
||||
it 'includes a reply link' do
|
||||
assert_select "a[href='#{@reply_link}']", text: /Reply/
|
||||
end
|
||||
|
||||
it 'should contain a link to your inbox' do
|
||||
it 'contains a link to your inbox' do
|
||||
assert_select "a[href*='notifications']"
|
||||
end
|
||||
|
||||
it 'should have fully qualified URLs' do
|
||||
it 'has fully qualified URLs' do
|
||||
# lots of lovely fully qualified URLs
|
||||
assert_select "a[href^='http']", minimum: 4
|
||||
# no relative URLs starting with /
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "photos/edit" do
|
||||
before(:each) do
|
||||
before do
|
||||
@photo = assign(:photo, stub_model(Photo,
|
||||
owner_id: 1,
|
||||
flickr_photo_id: 1,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "photos/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
page = 1
|
||||
per_page = 2
|
||||
total_entries = 2
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "photos/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
controller.stub(:current_user) { @member }
|
||||
page = 1
|
||||
@@ -22,7 +22,7 @@ describe "photos/new" do
|
||||
end
|
||||
|
||||
context "user has photosets" do
|
||||
before(:each) do
|
||||
before do
|
||||
assign(:sets, "foo" => "bar") # Hash of names => IDs
|
||||
end
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ describe "photos/show" do
|
||||
end
|
||||
|
||||
context "signed in as owner" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { member }
|
||||
render
|
||||
end
|
||||
@@ -58,7 +58,7 @@ describe "photos/show" do
|
||||
end
|
||||
|
||||
context "signed in as another member" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { FactoryBot.create :member }
|
||||
render
|
||||
end
|
||||
@@ -68,7 +68,7 @@ describe "photos/show" do
|
||||
end
|
||||
|
||||
context "not signed in" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
render
|
||||
end
|
||||
@@ -78,7 +78,7 @@ describe "photos/show" do
|
||||
end
|
||||
|
||||
context "CC-licensed photo" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
# @photo = assign(:photo, FactoryBot.create(:photo, owner: @member))
|
||||
@photo.harvests << harvest
|
||||
@@ -95,7 +95,7 @@ describe "photos/show" do
|
||||
end
|
||||
|
||||
context "unlicensed photo" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@photo = assign(:photo, FactoryBot.create(:unlicensed_photo))
|
||||
render
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "places/_map_attribution.html.haml", type: :view do
|
||||
before(:each) do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "places/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "places/show" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:london_member)
|
||||
@nearby_members = [FactoryBot.create(:member)]
|
||||
controller.stub(:current_user) { @member }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "plant_parts/edit" do
|
||||
before(:each) do
|
||||
before do
|
||||
@plant_part = assign(:plant_part, stub_model(PlantPart,
|
||||
name: "MyString"))
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "plant_parts/index" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@pp = FactoryBot.create(:plant_part)
|
||||
assign(:plant_parts, [@pp])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "plant_parts/new" do
|
||||
before(:each) do
|
||||
before do
|
||||
assign(:plant_part, stub_model(PlantPart,
|
||||
name: "MyString").as_new_record)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "plant_parts/show" do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
@pp = FactoryBot.create(:plant_part)
|
||||
@harvest = FactoryBot.create(:harvest, plant_part: @pp)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "plantings/_form" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member)
|
||||
@garden = FactoryBot.create(:garden, owner: @member)
|
||||
@uppercase = FactoryBot.create(:uppercasecrop)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "plantings/edit" do
|
||||
before(:each) do
|
||||
before do
|
||||
@member = FactoryBot.create(:member,
|
||||
login_name: 'right',
|
||||
email: 'right@example.com')
|
||||
@@ -20,7 +20,7 @@ describe "plantings/edit" do
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
before do
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
render
|
||||
|
||||
@@ -6,7 +6,7 @@ describe "plantings/index" do
|
||||
let(:tomato) { FactoryBot.create(:tomato) }
|
||||
let(:maize) { FactoryBot.create(:maize) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
page = 1
|
||||
per_page = 3
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'plantings/index.rss.haml' do
|
||||
before(:each) do
|
||||
before do
|
||||
controller.stub(:current_user) { nil }
|
||||
end
|
||||
|
||||
context 'all plantings' do
|
||||
before :each do
|
||||
before do
|
||||
@planting = FactoryBot.create(:planting)
|
||||
@sunny = FactoryBot.create(:sunny_planting)
|
||||
@seedling = FactoryBot.create(:seedling_planting)
|
||||
@@ -36,7 +36,7 @@ describe 'plantings/index.rss.haml' do
|
||||
end
|
||||
|
||||
context "one person's plantings" do
|
||||
before :each do
|
||||
before do
|
||||
@planting = FactoryBot.create(:planting)
|
||||
assign(:plantings, [@planting])
|
||||
assign(:owner, @planting.owner)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user