comment out unused specs

This commit is contained in:
Andrew Brown 2021-05-21 13:23:07 -07:00
parent bfa9b59100
commit 7451cd5013
26 changed files with 839 additions and 839 deletions

View File

@ -1,52 +1,52 @@
require 'rails_helper'
# require 'rails_helper'
describe HasAttributes do
let(:user) { create(:user) }
let(:category) { create(:attribute_category, entity_type: 'universe', user: user) }
let(:field) { create(:attribute_field, attribute_category: category, user: user, name: 'foo') }
# describe HasAttributes do
# let(:user) { create(:user) }
# let(:category) { create(:attribute_category, entity_type: 'universe', user: user) }
# let(:field) { create(:attribute_field, attribute_category: category, user: user, name: 'foo') }
describe '.attribute_categories' do
let(:categories) { Universe.attribute_categories(user) }
# describe '.attribute_categories' do
# let(:categories) { Universe.attribute_categories(user) }
context 'without a user' do
let(:user) { nil }
# context 'without a user' do
# let(:user) { nil }
it 'returns an array of AttributeCategory' do
expect(categories).to be_a_kind_of(Array)
expect(categories.first).to be_a_kind_of(AttributeCategory)
end
end
# it 'returns an array of AttributeCategory' do
# expect(categories).to be_a_kind_of(Array)
# expect(categories.first).to be_a_kind_of(AttributeCategory)
# end
# end
context 'with a user' do
it 'returns an array of AttributeCategory' do
expect(categories).to be_a_kind_of(ActiveRecord::AssociationRelation)
expect(categories.first).to be_a_kind_of(AttributeCategory)
end
# context 'with a user' do
# it 'returns an array of AttributeCategory' do
# expect(categories).to be_a_kind_of(ActiveRecord::AssociationRelation)
# expect(categories.first).to be_a_kind_of(AttributeCategory)
# end
context 'with custom attributes' do
before { field }
# context 'with custom attributes' do
# before { field }
it 'includes custom attribute categories' do
expect(categories).to include(category)
end
end
end
end
# it 'includes custom attribute categories' do
# expect(categories).to include(category)
# end
# end
# end
# end
describe '#update_custom_attributes' do
subject { create(:universe, user: user) }
let(:values) { [{ name: field.name }] }
# describe '#update_custom_attributes' do
# subject { create(:universe, user: user) }
# let(:values) { [{ name: field.name }] }
before do
subject.custom_attribute_values = values
end
# before do
# subject.custom_attribute_values = values
# end
context 'with attached custom attribute values' do
it 'saves attribute field values' do
expect {
subject.save
}.to change{Attribute.count}.from(0).to(1)
end
end
end
end
# context 'with attached custom attribute values' do
# it 'saves attribute field values' do
# expect {
# subject.save
# }.to change{Attribute.count}.from(0).to(1)
# end
# end
# end
# end

View File

@ -1,36 +1,36 @@
require 'rails_helper'
require 'support/devise'
# require 'rails_helper'
# require 'support/devise'
RSpec.describe AdminController, type: :controller do
describe 'admin user' do
before do
user = create(:user)
user.update(site_administrator: true)
sign_in user
end
# RSpec.describe AdminController, type: :controller do
# describe 'admin user' do
# before do
# user = create(:user)
# user.update(site_administrator: true)
# sign_in user
# end
describe 'GET #dashboard' do
before { get :dashboard }
it { is_expected.to respond_with(200) }
end
end
# describe 'GET #dashboard' do
# before { get :dashboard }
# it { is_expected.to respond_with(200) }
# end
# end
describe 'non-admin user' do
before do
user = create(:user)
sign_in user
end
# describe 'non-admin user' do
# before do
# user = create(:user)
# sign_in user
# end
describe 'GET #dashboard' do
before { get :dashboard }
it { is_expected.to respond_with(302) }
end
end
# describe 'GET #dashboard' do
# before { get :dashboard }
# it { is_expected.to respond_with(302) }
# end
# end
describe 'logged out user' do
describe 'GET #dashboard' do
before { get :dashboard }
it { is_expected.to respond_with(302) }
end
end
end
# describe 'logged out user' do
# describe 'GET #dashboard' do
# before { get :dashboard }
# it { is_expected.to respond_with(302) }
# end
# end
# end

View File

@ -1,7 +1,7 @@
require 'rails_helper'
require 'support/devise'
require 'support/content_controller_example'
# require 'rails_helper'
# require 'support/devise'
# require 'support/content_controller_example'
RSpec.describe AttributeFieldsController, type: :controller do
it_behaves_like 'a controller for a content item'
end
# RSpec.describe AttributeFieldsController, type: :controller do
# it_behaves_like 'a controller for a content item'
# end

View File

@ -1,7 +1,7 @@
require 'rails_helper'
require 'support/devise'
require 'support/content_controller_example'
# require 'rails_helper'
# require 'support/devise'
# require 'support/content_controller_example'
RSpec.describe CharactersController, type: :controller do
it_behaves_like 'a controller for a content item'
end
# RSpec.describe CharactersController, type: :controller do
# it_behaves_like 'a controller for a content item'
# end

View File

@ -1,182 +1,182 @@
require 'rails_helper'
require 'support/devise'
# require 'rails_helper'
# require 'support/devise'
RSpec.describe CharactersGeneratorController, type: :controller do
describe 'GET #age' do
before { get :age }
it { is_expected.to respond_with(200) }
# RSpec.describe CharactersGeneratorController, type: :controller do
# describe 'GET #age' do
# before { get :age }
# it { is_expected.to respond_with(200) }
describe 'assigns(:lower_limit)' do
subject { assigns(:lower_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be <= assigns(:upper_limit) }
end
# describe 'assigns(:lower_limit)' do
# subject { assigns(:lower_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be <= assigns(:upper_limit) }
# end
describe 'assigns(:upper_limit)' do
subject { assigns(:upper_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be >= assigns(:lower_limit) }
end
end
# describe 'assigns(:upper_limit)' do
# subject { assigns(:upper_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be >= assigns(:lower_limit) }
# end
# end
describe 'GET #bodytype' do
before { get :bodytype }
it { is_expected.to respond_with(200) }
# describe 'GET #bodytype' do
# before { get :bodytype }
# it { is_expected.to respond_with(200) }
describe 'assigns(:possible_types)' do
subject { assigns(:possible_types) }
it { is_expected.to_not be_empty }
end
end
# describe 'assigns(:possible_types)' do
# subject { assigns(:possible_types) }
# it { is_expected.to_not be_empty }
# end
# end
describe 'GET #eyecolor' do
before { get :eyecolor }
it { is_expected.to respond_with(200) }
# describe 'GET #eyecolor' do
# before { get :eyecolor }
# it { is_expected.to respond_with(200) }
describe 'assigns(:possible_colors)' do
subject { assigns(:possible_colors) }
it { is_expected.to_not be_empty }
end
end
# describe 'assigns(:possible_colors)' do
# subject { assigns(:possible_colors) }
# it { is_expected.to_not be_empty }
# end
# end
describe 'GET #facialhair' do
before { get :facialhair }
it { is_expected.to respond_with(200) }
# describe 'GET #facialhair' do
# before { get :facialhair }
# it { is_expected.to respond_with(200) }
describe 'assigns(:possible_types)' do
subject { assigns(:possible_styles) }
it { is_expected.to_not be_empty }
end
end
# describe 'assigns(:possible_types)' do
# subject { assigns(:possible_styles) }
# it { is_expected.to_not be_empty }
# end
# end
describe 'GET #haircolor' do
before { get :haircolor }
it { is_expected.to respond_with(200) }
# describe 'GET #haircolor' do
# before { get :haircolor }
# it { is_expected.to respond_with(200) }
describe 'assigns(:possible_colors)' do
subject { assigns(:possible_colors) }
it { is_expected.to_not be_empty }
end
end
# describe 'assigns(:possible_colors)' do
# subject { assigns(:possible_colors) }
# it { is_expected.to_not be_empty }
# end
# end
describe 'GET #hairstyle' do
before { get :hairstyle }
it { is_expected.to respond_with(200) }
# describe 'GET #hairstyle' do
# before { get :hairstyle }
# it { is_expected.to respond_with(200) }
describe 'assigns(:possible_styles)' do
subject { assigns(:possible_styles) }
it { is_expected.to_not be_empty }
end
end
# describe 'assigns(:possible_styles)' do
# subject { assigns(:possible_styles) }
# it { is_expected.to_not be_empty }
# end
# end
describe 'GET #height' do
before { get :height }
it { is_expected.to respond_with(200) }
# describe 'GET #height' do
# before { get :height }
# it { is_expected.to respond_with(200) }
describe 'assigns(:lower_foot_limit)' do
subject { assigns(:lower_foot_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be >= 0 }
it { is_expected.to be <= assigns(:upper_foot_limit) }
end
# describe 'assigns(:lower_foot_limit)' do
# subject { assigns(:lower_foot_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be >= 0 }
# it { is_expected.to be <= assigns(:upper_foot_limit) }
# end
describe 'assigns(:upper_foot_limit)' do
subject { assigns(:upper_foot_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be >= 0 }
it { is_expected.to be >= assigns(:lower_foot_limit) }
end
# describe 'assigns(:upper_foot_limit)' do
# subject { assigns(:upper_foot_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be >= 0 }
# it { is_expected.to be >= assigns(:lower_foot_limit) }
# end
describe 'assigns(:lower_inch_limit)' do
subject { assigns(:lower_inch_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be >= 0 }
it { is_expected.to be <= assigns(:upper_inch_limit) }
end
# describe 'assigns(:lower_inch_limit)' do
# subject { assigns(:lower_inch_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be >= 0 }
# it { is_expected.to be <= assigns(:upper_inch_limit) }
# end
describe 'assigns(:upper_inch_limit)' do
subject { assigns(:upper_inch_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be >= 0 }
it { is_expected.to be >= assigns(:lower_inch_limit) }
end
end
# describe 'assigns(:upper_inch_limit)' do
# subject { assigns(:upper_inch_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be >= 0 }
# it { is_expected.to be >= assigns(:lower_inch_limit) }
# end
# end
describe 'GET #identifyingmark' do
before { get :identifyingmark }
it { is_expected.to respond_with(200) }
# describe 'GET #identifyingmark' do
# before { get :identifyingmark }
# it { is_expected.to respond_with(200) }
describe 'assigns(:possible_marks)' do
subject { assigns(:possible_marks) }
it { is_expected.to_not be_nil }
end
# describe 'assigns(:possible_marks)' do
# subject { assigns(:possible_marks) }
# it { is_expected.to_not be_nil }
# end
describe 'assigns(:possible_locations)' do
subject { assigns(:possible_locations) }
it { is_expected.to_not be_nil }
end
end
# describe 'assigns(:possible_locations)' do
# subject { assigns(:possible_locations) }
# it { is_expected.to_not be_nil }
# end
# end
describe 'GET #name' do
before { get :name }
it { is_expected.to respond_with(200) }
# describe 'GET #name' do
# before { get :name }
# it { is_expected.to respond_with(200) }
describe 'assigns(:male_first_names)' do
subject { assigns(:male_first_names) }
it { is_expected.to_not be_empty }
end
# describe 'assigns(:male_first_names)' do
# subject { assigns(:male_first_names) }
# it { is_expected.to_not be_empty }
# end
describe 'assigns(:female_first_names)' do
subject { assigns(:female_first_names) }
it { is_expected.to_not be_empty }
end
# describe 'assigns(:female_first_names)' do
# subject { assigns(:female_first_names) }
# it { is_expected.to_not be_empty }
# end
describe 'assigns(:last_names)' do
subject { assigns(:last_names) }
it { is_expected.to_not be_empty }
end
# describe 'assigns(:last_names)' do
# subject { assigns(:last_names) }
# it { is_expected.to_not be_empty }
# end
describe 'assigns(:all_first_names)' do
subject { assigns(:all_first_names) }
it { is_expected.to_not be_empty }
end
# describe 'assigns(:all_first_names)' do
# subject { assigns(:all_first_names) }
# it { is_expected.to_not be_empty }
# end
describe 'assigns(:all_last_names)' do
subject { assigns(:all_last_names) }
it { is_expected.to_not be_empty }
end
end
# describe 'assigns(:all_last_names)' do
# subject { assigns(:all_last_names) }
# it { is_expected.to_not be_empty }
# end
# end
describe 'GET #race' do
before { get :race }
it { is_expected.to respond_with(200) }
# describe 'GET #race' do
# before { get :race }
# it { is_expected.to respond_with(200) }
describe 'assigns(:possible_races)' do
subject { assigns(:possible_races) }
it { is_expected.to_not be_empty }
end
end
# describe 'assigns(:possible_races)' do
# subject { assigns(:possible_races) }
# it { is_expected.to_not be_empty }
# end
# end
describe 'GET #skintone' do
before { get :bodytype }
it { is_expected.to respond_with(200) }
end
# describe 'GET #skintone' do
# before { get :bodytype }
# it { is_expected.to respond_with(200) }
# end
describe 'GET #weight' do
before { get :weight }
it { is_expected.to respond_with(200) }
# describe 'GET #weight' do
# before { get :weight }
# it { is_expected.to respond_with(200) }
describe 'assigns(:lower_limit)' do
subject { assigns(:lower_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be > 0 }
it { is_expected.to be <= assigns(:upper_limit) }
end
# describe 'assigns(:lower_limit)' do
# subject { assigns(:lower_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be > 0 }
# it { is_expected.to be <= assigns(:upper_limit) }
# end
describe 'assigns(:upper_limit)' do
subject { assigns(:upper_limit) }
it { is_expected.to be_an(Integer) }
it { is_expected.to be >= assigns(:lower_limit) }
end
end
end
# describe 'assigns(:upper_limit)' do
# subject { assigns(:upper_limit) }
# it { is_expected.to be_an(Integer) }
# it { is_expected.to be >= assigns(:lower_limit) }
# end
# end
# end

View File

@ -1,48 +1,48 @@
require 'rails_helper'
require 'support/generated_lists_example'
# require 'rails_helper'
# require 'support/generated_lists_example'
RSpec.describe EquipmentGeneratorController, type: :controller do
it_behaves_like 'a generator', :shield_types do
before { get :armor_shield }
end
# RSpec.describe EquipmentGeneratorController, type: :controller do
# it_behaves_like 'a generator', :shield_types do
# before { get :armor_shield }
# end
it_behaves_like 'a generator', :weapon_types do
before { get :weapon }
end
# it_behaves_like 'a generator', :weapon_types do
# before { get :weapon }
# end
it_behaves_like 'a generator', :axe_types do
before { get :weapon_axe }
end
# it_behaves_like 'a generator', :axe_types do
# before { get :weapon_axe }
# end
it_behaves_like 'a generator', :bow_types do
before { get :weapon_bow }
end
# it_behaves_like 'a generator', :bow_types do
# before { get :weapon_bow }
# end
it_behaves_like 'a generator', :club_types do
before { get :weapon_club }
end
# it_behaves_like 'a generator', :club_types do
# before { get :weapon_club }
# end
it_behaves_like 'a generator', :fist_weapon_types do
before { get :weapon_fist }
end
# it_behaves_like 'a generator', :fist_weapon_types do
# before { get :weapon_fist }
# end
it_behaves_like 'a generator', :flexible_types do
before { get :weapon_flexible }
end
# it_behaves_like 'a generator', :flexible_types do
# before { get :weapon_flexible }
# end
it_behaves_like 'a generator', :thrown_types do
before { get :weapon_thrown }
end
# it_behaves_like 'a generator', :thrown_types do
# before { get :weapon_thrown }
# end
it_behaves_like 'a generator', :polearm_types do
before { get :weapon_polearm }
end
# it_behaves_like 'a generator', :polearm_types do
# before { get :weapon_polearm }
# end
it_behaves_like 'a generator', :shortsword_types do
before { get :weapon_shortsword }
end
# it_behaves_like 'a generator', :shortsword_types do
# before { get :weapon_shortsword }
# end
it_behaves_like 'a generator', :sword_types do
before { get :weapon_sword }
end
end
# it_behaves_like 'a generator', :sword_types do
# before { get :weapon_sword }
# end
# end

View File

@ -1,7 +1,7 @@
require 'rails_helper'
require 'support/devise'
require 'support/content_controller_example'
# require 'rails_helper'
# require 'support/devise'
# require 'support/content_controller_example'
RSpec.describe ItemsController, type: :controller do
it_behaves_like 'a controller for a content item'
end
# RSpec.describe ItemsController, type: :controller do
# it_behaves_like 'a controller for a content item'
# end

View File

@ -1,7 +1,7 @@
require 'rails_helper'
require 'support/devise'
require 'support/content_controller_example'
# require 'rails_helper'
# require 'support/devise'
# require 'support/content_controller_example'
RSpec.describe LocationsController, type: :controller do
it_behaves_like 'a controller for a content item'
end
# RSpec.describe LocationsController, type: :controller do
# it_behaves_like 'a controller for a content item'
# end

View File

@ -1,55 +1,55 @@
require 'rails_helper'
require 'support/devise'
# require 'rails_helper'
# require 'support/devise'
RSpec.describe LocationsGeneratorController, type: :controller do
describe 'GET #name' do
before { get :name }
# RSpec.describe LocationsGeneratorController, type: :controller do
# describe 'GET #name' do
# before { get :name }
it { is_expected.to respond_with(200) }
# it { is_expected.to respond_with(200) }
describe 'assigns(:root_name)' do
subject { assigns(:root_name) }
it { is_expected.to_not be_blank }
end
# describe 'assigns(:root_name)' do
# subject { assigns(:root_name) }
# it { is_expected.to_not be_blank }
# end
describe 'assigns(:prefix_occurrence)' do
subject { assigns(:prefix_occurrence) }
it { is_expected.to_not be_blank }
it { is_expected.to be_between(0, 1).inclusive }
end
# describe 'assigns(:prefix_occurrence)' do
# subject { assigns(:prefix_occurrence) }
# it { is_expected.to_not be_blank }
# it { is_expected.to be_between(0, 1).inclusive }
# end
describe 'assigns(:postfix_occurrence)' do
subject { assigns(:postfix_occurrence) }
it { is_expected.to_not be_blank }
it { is_expected.to be_between(0, 1).inclusive }
end
# describe 'assigns(:postfix_occurrence)' do
# subject { assigns(:postfix_occurrence) }
# it { is_expected.to_not be_blank }
# it { is_expected.to be_between(0, 1).inclusive }
# end
describe 'assigns(:syllables_upper_limit)' do
subject { assigns(:syllables_upper_limit) }
it { is_expected.to_not be_blank }
it { is_expected.to be >= assigns(:syllables_lower_limit) }
end
# describe 'assigns(:syllables_upper_limit)' do
# subject { assigns(:syllables_upper_limit) }
# it { is_expected.to_not be_blank }
# it { is_expected.to be >= assigns(:syllables_lower_limit) }
# end
describe 'assigns(:syllables_lower_limit)' do
subject { assigns(:syllables_lower_limit) }
it { is_expected.to_not be_blank }
it { is_expected.to be >= 0 }
it { is_expected.to be <= assigns(:syllables_upper_limit) }
end
# describe 'assigns(:syllables_lower_limit)' do
# subject { assigns(:syllables_lower_limit) }
# it { is_expected.to_not be_blank }
# it { is_expected.to be >= 0 }
# it { is_expected.to be <= assigns(:syllables_upper_limit) }
# end
describe 'assigns(:prefixes)' do
subject { assigns(:prefixes) }
it { is_expected.to_not be_blank }
end
# describe 'assigns(:prefixes)' do
# subject { assigns(:prefixes) }
# it { is_expected.to_not be_blank }
# end
describe 'assigns(:postfixes)' do
subject { assigns(:postfixes) }
it { is_expected.to_not be_blank }
end
# describe 'assigns(:postfixes)' do
# subject { assigns(:postfixes) }
# it { is_expected.to_not be_blank }
# end
describe 'assigns(:syllables)' do
subject { assigns(:syllables) }
it { is_expected.to_not be_blank }
end
end
end
# describe 'assigns(:syllables)' do
# subject { assigns(:syllables) }
# it { is_expected.to_not be_blank }
# end
# end
# end

View File

@ -1,9 +1,9 @@
require 'rails_helper'
require 'support/devise'
# require 'rails_helper'
# require 'support/devise'
RSpec.describe MainController, type: :controller do
describe 'GET #index' do
before { get :index }
it { is_expected.to respond_with(200) }
end
end
# RSpec.describe MainController, type: :controller do
# describe 'GET #index' do
# before { get :index }
# it { is_expected.to respond_with(200) }
# end
# end

View File

@ -1,257 +1,257 @@
require 'rails_helper'
require 'support/devise'
require 'webmock/rspec'
include Rails.application.routes.url_helpers
# require 'rails_helper'
# require 'support/devise'
# require 'webmock/rspec'
# include Rails.application.routes.url_helpers
RSpec.describe SubscriptionsController, type: :controller do
before do
WebMock.disable_net_connect!(allow_localhost: true)
# RSpec.describe SubscriptionsController, type: :controller do
# before do
# WebMock.disable_net_connect!(allow_localhost: true)
# Need to stub .save on StripeObject, but this doesn't seem to work
#Stripe::StripeObject.any_instance.stub(:save).and_return(true)
# # Need to stub .save on StripeObject, but this doesn't seem to work
# #Stripe::StripeObject.any_instance.stub(:save).and_return(true)
# Stub Stripe::Customer.create
stub_request(:post, "https://api.stripe.com/v1/customers")
.with(body: { email: "email1@example.com" })
.to_return(status: 200, body: {id: 'stripe-id'}.to_json, headers: {})
# # Stub Stripe::Customer.create
# stub_request(:post, "https://api.stripe.com/v1/customers")
# .with(body: { email: "email1@example.com" })
# .to_return(status: 200, body: {id: 'stripe-id'}.to_json, headers: {})
# Stub Stripe::Customer.retrieve
stub_request(:get, "https://api.stripe.com/v1/customers/stripe-id")
.to_return(
status: 200,
body: {
id: 'stripe-id',
sources: {
total_count: 0,
data: []
},
subscriptions: {
total_count: 1,
data: [Stripe::StripeObject.new]
}
}.to_json,
headers: {}
)
# # Stub Stripe::Customer.retrieve
# stub_request(:get, "https://api.stripe.com/v1/customers/stripe-id")
# .to_return(
# status: 200,
# body: {
# id: 'stripe-id',
# sources: {
# total_count: 0,
# data: []
# },
# subscriptions: {
# total_count: 1,
# data: [Stripe::StripeObject.new]
# }
# }.to_json,
# headers: {}
# )
# Stub downgrading subscription to starter
stub_request(:post, "https://api.stripe.com/v1/subscriptions")
.with(body: { customer: "stripe-id", plan: 'starter' })
.to_return(status: 200, body: {id: 'stripe-id'}.to_json, headers: {})
# # Stub downgrading subscription to starter
# stub_request(:post, "https://api.stripe.com/v1/subscriptions")
# .with(body: { customer: "stripe-id", plan: 'starter' })
# .to_return(status: 200, body: {id: 'stripe-id'}.to_json, headers: {})
# Stub updating subscription to premium
stub_request(:post, "https://api.stripe.com/v1/subscriptions")
.with(body: { customer: "stripe-id", plan: 'premium' })
.to_return(status: 200, body: {id: 'stripe-id'}.to_json, headers: {})
# # Stub updating subscription to premium
# stub_request(:post, "https://api.stripe.com/v1/subscriptions")
# .with(body: { customer: "stripe-id", plan: 'premium' })
# .to_return(status: 200, body: {id: 'stripe-id'}.to_json, headers: {})
@request.env['devise.mapping'] = Devise.mappings[:user]
@user = create(:user)
@user.update(stripe_customer_id: 'stripe-id')
sign_in @user
# @request.env['devise.mapping'] = Devise.mappings[:user]
# @user = create(:user)
# @user.update(stripe_customer_id: 'stripe-id')
# sign_in @user
@free_plan = BillingPlan.create(
name: 'Starter',
stripe_plan_id: 'starter',
monthly_cents: 0, # $0.00/mo
available: true,
# @free_plan = BillingPlan.create(
# name: 'Starter',
# stripe_plan_id: 'starter',
# monthly_cents: 0, # $0.00/mo
# available: true,
# Content creation and other permissions:
universe_limit: 5,
allows_core_content: true,
allows_extended_content: false,
allows_collective_content: false,
allows_collaboration: false,
bonus_bandwidth_kb: 123155
)
# # Content creation and other permissions:
# universe_limit: 5,
# allows_core_content: true,
# allows_extended_content: false,
# allows_collective_content: false,
# allows_collaboration: false,
# bonus_bandwidth_kb: 123155
# )
@beta_plan = BillingPlan.create(
name: 'Early Adopters',
stripe_plan_id: 'early-adopters',
monthly_cents: 0, # $0.00/mo
available: true,
# @beta_plan = BillingPlan.create(
# name: 'Early Adopters',
# stripe_plan_id: 'early-adopters',
# monthly_cents: 0, # $0.00/mo
# available: true,
# Content creation and other permissions:
universe_limit: 5,
allows_core_content: true,
allows_extended_content: false,
allows_collective_content: false,
allows_collaboration: false,
bonus_bandwidth_kb: 123155
)
# # Content creation and other permissions:
# universe_limit: 5,
# allows_core_content: true,
# allows_extended_content: false,
# allows_collective_content: false,
# allows_collaboration: false,
# bonus_bandwidth_kb: 123155
# )
@premium_plan = BillingPlan.create(
name: 'Premium',
stripe_plan_id: 'premium',
monthly_cents: 900,
available: true,
universe_limit: 5,
allows_core_content: true,
allows_extended_content: true,
allows_collective_content: true,
allows_collaboration: true,
bonus_bandwidth_kb: 0
)
# @premium_plan = BillingPlan.create(
# name: 'Premium',
# stripe_plan_id: 'premium',
# monthly_cents: 900,
# available: true,
# universe_limit: 5,
# allows_core_content: true,
# allows_extended_content: true,
# allows_collective_content: true,
# allows_collaboration: true,
# bonus_bandwidth_kb: 0
# )
@premium_annual_plan = BillingPlan.create(
name: 'Premium (annual)',
stripe_plan_id: 'premium-annual',
monthly_cents: 700,
available: true,
universe_limit: 5,
allows_core_content: true,
allows_extended_content: true,
allows_collective_content: true,
allows_collaboration: true,
bonus_bandwidth_kb: 123155
)
end
# @premium_annual_plan = BillingPlan.create(
# name: 'Premium (annual)',
# stripe_plan_id: 'premium-annual',
# monthly_cents: 700,
# available: true,
# universe_limit: 5,
# allows_core_content: true,
# allows_extended_content: true,
# allows_collective_content: true,
# allows_collaboration: true,
# bonus_bandwidth_kb: 123155
# )
# end
describe "User with no plan (fallback to Starter) tries to upgrade" do
it "redirects to payment method form if they don't have a payment method saved" do
expect(@user.active_subscriptions).to eq([])
post :change, params: { stripe_plan_id: 'premium' }
expect(subject).to redirect_to action: :information, plan: 'premium'
end
end
# describe "User with no plan (fallback to Starter) tries to upgrade" do
# it "redirects to payment method form if they don't have a payment method saved" do
# expect(@user.active_subscriptions).to eq([])
# post :change, params: { stripe_plan_id: 'premium' }
# expect(subject).to redirect_to action: :information, plan: 'premium'
# end
# end
describe "User on Starter" do
before do
# Create a Starter subscription for the user
@user.update(selected_billing_plan_id: @free_plan.id)
end
# describe "User on Starter" do
# before do
# # Create a Starter subscription for the user
# @user.update(selected_billing_plan_id: @free_plan.id)
# end
it "redirects to payment method form if they don't have a payment method saved" do
post :change, params: { stripe_plan_id: 'premium' }
expect(subject).to redirect_to action: :information, plan: 'premium'
end
# it "redirects to payment method form if they don't have a payment method saved" do
# post :change, params: { stripe_plan_id: 'premium' }
# expect(subject).to redirect_to action: :information, plan: 'premium'
# end
it "allows upgrading to Premium when they have a payment method saved" do
# Re-stub Stripe::Customer.retrieve to include a payment method (source)
stub_request(:get, "https://api.stripe.com/v1/customers/stripe-id")
.to_return(
status: 200,
body: {
id: 'stripe-id',
sources: {
total_count: 1,
data: [Stripe::StripeObject.new]
},
subscriptions: {
total_count: 1,
data: [Stripe::StripeObject.new]
}
}.to_json,
headers: {}
)
# it "allows upgrading to Premium when they have a payment method saved" do
# # Re-stub Stripe::Customer.retrieve to include a payment method (source)
# stub_request(:get, "https://api.stripe.com/v1/customers/stripe-id")
# .to_return(
# status: 200,
# body: {
# id: 'stripe-id',
# sources: {
# total_count: 1,
# data: [Stripe::StripeObject.new]
# },
# subscriptions: {
# total_count: 1,
# data: [Stripe::StripeObject.new]
# }
# }.to_json,
# headers: {}
# )
expect(@user.selected_billing_plan_id).to eq(@free_plan.id)
expect(@user.active_billing_plans).not_to eq([@premium_plan])
# expect(@user.selected_billing_plan_id).to eq(@free_plan.id)
# expect(@user.active_billing_plans).not_to eq([@premium_plan])
post :change, params: { stripe_plan_id: 'premium' }
# post :change, params: { stripe_plan_id: 'premium' }
@user.reload
expect(@user.selected_billing_plan_id).to eq(@premium_plan.id)
expect(@user.active_billing_plans).to eq([@premium_plan])
end
# @user.reload
# expect(@user.selected_billing_plan_id).to eq(@premium_plan.id)
# expect(@user.active_billing_plans).to eq([@premium_plan])
# end
describe "Starter Permissions" do
before do
@user.update(selected_billing_plan_id: @free_plan.id)
end
# describe "Starter Permissions" do
# before do
# @user.update(selected_billing_plan_id: @free_plan.id)
# end
it "allows Starter users to create core content types" do
expect(@user.can_create?(Character)).to eq(true)
expect(@user.can_create?(Location)).to eq(true)
expect(@user.can_create?(Item)).to eq(true)
end
# it "allows Starter users to create core content types" do
# expect(@user.can_create?(Character)).to eq(true)
# expect(@user.can_create?(Location)).to eq(true)
# expect(@user.can_create?(Item)).to eq(true)
# end
it "doesn't allow Starter users to create extended content types" do
expect(@user.can_create?(Creature)).to eq(false)
expect(@user.can_create?(Race)).to eq(false)
expect(@user.can_create?(Religion)).to eq(false)
expect(@user.can_create?(Group)).to eq(false)
expect(@user.can_create?(Magic)).to eq(false)
expect(@user.can_create?(Language)).to eq(false)
expect(@user.can_create?(Flora)).to eq(false)
end
# it "doesn't allow Starter users to create extended content types" do
# expect(@user.can_create?(Creature)).to eq(false)
# expect(@user.can_create?(Race)).to eq(false)
# expect(@user.can_create?(Religion)).to eq(false)
# expect(@user.can_create?(Group)).to eq(false)
# expect(@user.can_create?(Magic)).to eq(false)
# expect(@user.can_create?(Language)).to eq(false)
# expect(@user.can_create?(Flora)).to eq(false)
# end
it "doesn't allow Starter users to create collective content types" do
expect(@user.can_create?(Scene)).to eq(false)
end
end
end
# it "doesn't allow Starter users to create collective content types" do
# expect(@user.can_create?(Scene)).to eq(false)
# end
# end
# end
describe "User on Premium" do
before do
# Create a premium subscription for the user
@user.update(selected_billing_plan_id: @premium_plan.id)
end
# describe "User on Premium" do
# before do
# # Create a premium subscription for the user
# @user.update(selected_billing_plan_id: @premium_plan.id)
# end
it "allows downgrading to Starter" do
# Downgrade to Starter
post :change, params: { stripe_plan_id: 'starter' }
# it "allows downgrading to Starter" do
# # Downgrade to Starter
# post :change, params: { stripe_plan_id: 'starter' }
@user.reload
expect(@user.selected_billing_plan_id).to eq(@free_plan.id)
expect(@user.active_billing_plans).to eq([@free_plan])
expect(@user.active_subscriptions.map(&:billing_plan_id)).to eq([@free_plan.id])
end
# @user.reload
# expect(@user.selected_billing_plan_id).to eq(@free_plan.id)
# expect(@user.active_billing_plans).to eq([@free_plan])
# expect(@user.active_subscriptions.map(&:billing_plan_id)).to eq([@free_plan.id])
# end
describe "Premium Permissions" do
it "allows Premium users to create core content types" do
@user.update(selected_billing_plan_id: 4)
expect(@user.can_create?(Character)).to eq(true)
expect(@user.can_create?(Location)).to eq(true)
expect(@user.can_create?(Item)).to eq(true)
end
# describe "Premium Permissions" do
# it "allows Premium users to create core content types" do
# @user.update(selected_billing_plan_id: 4)
# expect(@user.can_create?(Character)).to eq(true)
# expect(@user.can_create?(Location)).to eq(true)
# expect(@user.can_create?(Item)).to eq(true)
# end
it "allows Premium users to create extended content types" do
@user.update(selected_billing_plan_id: 4)
expect(@user.can_create?(Creature)).to eq(true)
expect(@user.can_create?(Race)).to eq(true)
expect(@user.can_create?(Religion)).to eq(true)
expect(@user.can_create?(Group)).to eq(true)
expect(@user.can_create?(Magic)).to eq(true)
expect(@user.can_create?(Language)).to eq(true)
expect(@user.can_create?(Flora)).to eq(true)
end
# it "allows Premium users to create extended content types" do
# @user.update(selected_billing_plan_id: 4)
# expect(@user.can_create?(Creature)).to eq(true)
# expect(@user.can_create?(Race)).to eq(true)
# expect(@user.can_create?(Religion)).to eq(true)
# expect(@user.can_create?(Group)).to eq(true)
# expect(@user.can_create?(Magic)).to eq(true)
# expect(@user.can_create?(Language)).to eq(true)
# expect(@user.can_create?(Flora)).to eq(true)
# end
it "allows Premium users to create collective content types" do
@user.update(selected_billing_plan_id: 4)
expect(@user.can_create?(Scene)).to eq(true)
end
end
end
# it "allows Premium users to create collective content types" do
# @user.update(selected_billing_plan_id: 4)
# expect(@user.can_create?(Scene)).to eq(true)
# end
# end
# end
describe "Upload storage adjustments" do
before do
@user.active_subscriptions.create(billing_plan: @free_plan, start_date: Time.now - 5.days, end_date: Time.now + 5.days)
@user.update(selected_billing_plan_id: @free_plan.id)
end
# describe "Upload storage adjustments" do
# before do
# @user.active_subscriptions.create(billing_plan: @free_plan, start_date: Time.now - 5.days, end_date: Time.now + 5.days)
# @user.update(selected_billing_plan_id: @free_plan.id)
# end
it 'grants storage space to a user after upgrading' do
@user.update(upload_bandwidth_kb: 100)
post :change, params: { stripe_plan_id: 'premium' }
expect(@user.upload_bandwidth_kb).to eq(100 + @premium_plan.bonus_bandwidth_kb)
end
# it 'grants storage space to a user after upgrading' do
# @user.update(upload_bandwidth_kb: 100)
# post :change, params: { stripe_plan_id: 'premium' }
# expect(@user.upload_bandwidth_kb).to eq(100 + @premium_plan.bonus_bandwidth_kb)
# end
it 'decreases storage space for a user after downgrading' do
@user.update(upload_bandwidth_kb: 100)
post :change, params: { stripe_plan_id: 'starter' }
expect(@user.upload_bandwidth_kb).to eq(100 - @premium_plan.bonus_bandwidth_kb)
end
# it 'decreases storage space for a user after downgrading' do
# @user.update(upload_bandwidth_kb: 100)
# post :change, params: { stripe_plan_id: 'starter' }
# expect(@user.upload_bandwidth_kb).to eq(100 - @premium_plan.bonus_bandwidth_kb)
# end
it 'does not adjust storage space when going premium --> premium' do
@user.update(upload_bandwidth_kb: 101)
@user.update(selected_billing_plan_id: @premium_plan.id)
post :change, params: { stripe_plan_id: @premium_annual_plan.stripe_plan_id }
expect(@user.upload_bandwidth_kb).to eq(101)
end
# it 'does not adjust storage space when going premium --> premium' do
# @user.update(upload_bandwidth_kb: 101)
# @user.update(selected_billing_plan_id: @premium_plan.id)
# post :change, params: { stripe_plan_id: @premium_annual_plan.stripe_plan_id }
# expect(@user.upload_bandwidth_kb).to eq(101)
# end
it 'does not adjust storage space if no plan change is made' do
@user.update(upload_bandwidth_kb: 101)
@user.update(selected_billing_plan_id: @premium_annual_plan.stripe_plan_id)
post :change, params: { stripe_plan_id: @premium_plan.stripe_plan_id }
expect(@user.upload_bandwidth_kb).to eq(101)
end
end
end
# it 'does not adjust storage space if no plan change is made' do
# @user.update(upload_bandwidth_kb: 101)
# @user.update(selected_billing_plan_id: @premium_annual_plan.stripe_plan_id)
# post :change, params: { stripe_plan_id: @premium_plan.stripe_plan_id }
# expect(@user.upload_bandwidth_kb).to eq(101)
# end
# end
# end

View File

@ -1,7 +1,7 @@
require 'rails_helper'
require 'support/devise'
require 'support/content_controller_example'
# require 'rails_helper'
# require 'support/devise'
# require 'support/content_controller_example'
RSpec.describe UniversesController, type: :controller do
it_behaves_like 'a controller for a content item'
end
# RSpec.describe UniversesController, type: :controller do
# it_behaves_like 'a controller for a content item'
# end

View File

@ -1,14 +1,14 @@
require 'rails_helper'
require 'support/devise'
# require 'rails_helper'
# require 'support/devise'
RSpec.describe UsersController, type: :controller do
let(:user) { create(:user) }
# RSpec.describe UsersController, type: :controller do
# let(:user) { create(:user) }
describe 'GET #show/:id' do
it 'responds successfully with an HTTP 200 status code' do
get :show, params: { id: user.id }
expect(response).to be_successful
expect(response).to have_http_status(200)
end
end
end
# describe 'GET #show/:id' do
# it 'responds successfully with an HTTP 200 status code' do
# get :show, params: { id: user.id }
# expect(response).to be_successful
# expect(response).to have_http_status(200)
# end
# end
# end

View File

@ -1,17 +1,17 @@
require 'rails_helper'
require 'support/devise'
# require 'rails_helper'
# require 'support/devise'
RSpec.describe WriteController, type: :controller do
describe 'GET #editor, scene_id: 1' do
before do
@request.env['devise.mapping'] = Devise.mappings[:user]
@user = create(:user)
# RSpec.describe WriteController, type: :controller do
# describe 'GET #editor, scene_id: 1' do
# before do
# @request.env['devise.mapping'] = Devise.mappings[:user]
# @user = create(:user)
sign_in @user
# sign_in @user
get :editor, params: { scene_id: 1 }
end
# get :editor, params: { scene_id: 1 }
# end
it { is_expected.to respond_with(200) }
end
end
# it { is_expected.to respond_with(200) }
# end
# end

View File

@ -1,15 +1,15 @@
require "spec_helper"
# require "spec_helper"
describe AttributesHelper do
let(:content) { create(:universe) }
let(:category) { create(:attribute_category) }
# describe AttributesHelper do
# let(:content) { create(:universe) }
# let(:category) { create(:attribute_category) }
describe '#attribute_category_tab' do
let(:result) { helper.attribute_category_tab(content, category) }
# describe '#attribute_category_tab' do
# let(:result) { helper.attribute_category_tab(content, category) }
it "returns an html string" do
expect(result).to be_a_kind_of(String)
expect(result.html_safe?).to be true
end
end
end
# it "returns an html string" do
# expect(result).to be_a_kind_of(String)
# expect(result.html_safe?).to be true
# end
# end
# end

View File

@ -1,29 +1,29 @@
require 'rails_helper'
require 'support/privacy_example'
require 'support/public_scope_example'
# require 'rails_helper'
# require 'support/privacy_example'
# require 'support/public_scope_example'
RSpec.describe Character, type: :model do
it_behaves_like 'content with privacy'
it_behaves_like 'content with an is_public scope'
# RSpec.describe Character, type: :model do
# it_behaves_like 'content with privacy'
# it_behaves_like 'content with an is_public scope'
context "when character having a sibling is deleted" do
before do
@alice = create(:character, name: "Alice")
@bob = create(:character, name: "Bob")
@alice.siblings << @bob
@alice.destroy()
end
# context "when character having a sibling is deleted" do
# before do
# @alice = create(:character, name: "Alice")
# @bob = create(:character, name: "Bob")
# @alice.siblings << @bob
# @alice.destroy()
# end
it "don't delete the sibling" do
expect(Character.exists?(@bob.id)).to be true
end
# it "don't delete the sibling" do
# expect(Character.exists?(@bob.id)).to be true
# end
it "delete sibling relation" do
expect(@alice.siblings.include?(@bob)).to be false
end
# it "delete sibling relation" do
# expect(@alice.siblings.include?(@bob)).to be false
# end
it "delete reverse sibling relation" do
expect(@bob.siblings.include?(@alice)).to be false
end
end
end
# it "delete reverse sibling relation" do
# expect(@bob.siblings.include?(@alice)).to be false
# end
# end
# end

View File

@ -1,9 +1,9 @@
require 'rails_helper'
require 'support/privacy_example'
require 'support/public_scope_example'
# require 'rails_helper'
# require 'support/privacy_example'
# require 'support/public_scope_example'
RSpec.describe Item, type: :model do
it_behaves_like 'content with privacy'
it_behaves_like 'content with an is_public scope'
it { is_expected.to validate_presence_of(:name) }
end
# RSpec.describe Item, type: :model do
# it_behaves_like 'content with privacy'
# it_behaves_like 'content with an is_public scope'
# it { is_expected.to validate_presence_of(:name) }
# end

View File

@ -1,9 +1,9 @@
require 'rails_helper'
require 'support/privacy_example'
require 'support/public_scope_example'
# require 'rails_helper'
# require 'support/privacy_example'
# require 'support/public_scope_example'
RSpec.describe Location, type: :model do
it_behaves_like 'content with privacy'
it_behaves_like 'content with an is_public scope'
it { is_expected.to validate_presence_of(:name) }
end
# RSpec.describe Location, type: :model do
# it_behaves_like 'content with privacy'
# it_behaves_like 'content with an is_public scope'
# it { is_expected.to validate_presence_of(:name) }
# end

View File

@ -1,8 +1,8 @@
require 'rails_helper'
require 'support/privacy_example'
require 'support/public_scope_example'
# require 'rails_helper'
# require 'support/privacy_example'
# require 'support/public_scope_example'
RSpec.describe Universe, type: :model do
it_behaves_like 'content with privacy'
it { is_expected.to validate_presence_of(:name) }
end
# RSpec.describe Universe, type: :model do
# it_behaves_like 'content with privacy'
# it { is_expected.to validate_presence_of(:name) }
# end

View File

@ -1,12 +1,12 @@
require 'rails_helper'
# require 'rails_helper'
RSpec.describe User, type: :model do
context "when user's email is profile.image.test@example.com" do
let(:user) { build(:user, email: 'profile.image.test@example.com') }
# RSpec.describe User, type: :model do
# context "when user's email is profile.image.test@example.com" do
# let(:user) { build(:user, email: 'profile.image.test@example.com') }
describe '.image_url' do
subject { user.image_url }
it { is_expected.to match('https://www.gravatar.com/avatar/d2fd00e79c471f49c33b6bcb6b08d08d') }
end
end
end
# describe '.image_url' do
# subject { user.image_url }
# it { is_expected.to match('https://www.gravatar.com/avatar/d2fd00e79c471f49c33b6bcb6b08d08d') }
# end
# end
# end

View File

@ -1,74 +1,74 @@
require 'rails_helper'
require 'support/devise'
include Rails.application.routes.url_helpers
# require 'rails_helper'
# require 'support/devise'
# include Rails.application.routes.url_helpers
shared_examples_for 'a controller for a content item' do
before(:all) do
@model_class = described_class.controller_name.classify.constantize
@model_name = described_class.controller_name.classify.constantize.model_name.param_key
end
# shared_examples_for 'a controller for a content item' do
# before(:all) do
# @model_class = described_class.controller_name.classify.constantize
# @model_name = described_class.controller_name.classify.constantize.model_name.param_key
# end
before(:each) do
@request.env['devise.mapping'] = Devise.mappings[:user]
@user = create(:user)
# before(:each) do
# @request.env['devise.mapping'] = Devise.mappings[:user]
# @user = create(:user)
sign_in @user
end
# sign_in @user
# end
let(:model) { create(@model_name.to_sym, user: @user) }
# let(:model) { create(@model_name.to_sym, user: @user) }
describe 'GET #index' do
before { get :index }
it { is_expected.to respond_with(200) }
it { is_expected.to render_template('content/index') }
# describe 'GET #index' do
# before { get :index }
# it { is_expected.to respond_with(200) }
# it { is_expected.to render_template('content/index') }
describe 'assigns(:content)' do
subject { assigns(:content) }
it { is_expected.to_not be_nil }
end
end
# describe 'assigns(:content)' do
# subject { assigns(:content) }
# it { is_expected.to_not be_nil }
# end
# end
describe 'GET #new' do
before { get :new }
it { is_expected.to respond_with(200) }
it { is_expected.to render_template(locals: "#{@model_name.pluralize}/new", layout: :application) }
end
# describe 'GET #new' do
# before { get :new }
# it { is_expected.to respond_with(200) }
# it { is_expected.to render_template(locals: "#{@model_name.pluralize}/new", layout: :application) }
# end
describe 'POST #create' do
# todo change this to use custom attributes now
# before do
# post :create, params: { @model_name => {
# name: model.name,
# user: @user
# } }
# end
# it { is_expected.to redirect_to(polymorphic_path(assigns(:content))) }
end
# describe 'POST #create' do
# # todo change this to use custom attributes now
# # before do
# # post :create, params: { @model_name => {
# # name: model.name,
# # user: @user
# # } }
# # end
# # it { is_expected.to redirect_to(polymorphic_path(assigns(:content))) }
# end
describe 'GET #edit' do
before { get :edit, params: { id: model.id } }
it { is_expected.to respond_with(200) }
it { is_expected.to render_template(locals: "#{@model_name.pluralize}/edit", layout: :application) }
end
# describe 'GET #edit' do
# before { get :edit, params: { id: model.id } }
# it { is_expected.to respond_with(200) }
# it { is_expected.to render_template(locals: "#{@model_name.pluralize}/edit", layout: :application) }
# end
describe 'PUT #update' do
# todo change this to use custom attributes now
# before do
# put :update, params: { id: model.id, @model_name => {
# name: model.name,
# user: @user
# } }
# end
# it { is_expected.to redirect_to(polymorphic_path(model)) }
end
# describe 'PUT #update' do
# # todo change this to use custom attributes now
# # before do
# # put :update, params: { id: model.id, @model_name => {
# # name: model.name,
# # user: @user
# # } }
# # end
# # it { is_expected.to redirect_to(polymorphic_path(model)) }
# end
describe 'DELETE #destroy' do
before { delete :destroy, params: { id: model.id } }
it { is_expected.to redirect_to(polymorphic_path(@model_class)) }
# describe 'DELETE #destroy' do
# before { delete :destroy, params: { id: model.id } }
# it { is_expected.to redirect_to(polymorphic_path(@model_class)) }
describe 'the destroyed model' do
subject { @model_class.find_by_id(model.id) }
it { is_expected.to be_nil }
end
end
end
# describe 'the destroyed model' do
# subject { @model_class.find_by_id(model.id) }
# it { is_expected.to be_nil }
# end
# end
# end

View File

@ -1,5 +1,5 @@
require 'devise'
# require 'devise'
RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, type: :controller
end
# RSpec.configure do |config|
# config.include Devise::Test::ControllerHelpers, type: :controller
# end

View File

@ -1,9 +1,9 @@
require 'rails_helper'
# require 'rails_helper'
shared_examples_for 'a generator' do |types|
it { is_expected.to respond_with(200) }
# shared_examples_for 'a generator' do |types|
# it { is_expected.to respond_with(200) }
it "assigns #{types}" do
expect(assigns(types)).to_not be_empty
end
end
# it "assigns #{types}" do
# expect(assigns(types)).to_not be_empty
# end
# end

View File

@ -1,17 +1,17 @@
require 'rails_helper'
# require 'rails_helper'
shared_examples_for 'content with privacy' do
context 'model is public' do
let(:model) do
build(
described_class.model_name.param_key.to_sym,
privacy: 'public'
)
end
# shared_examples_for 'content with privacy' do
# context 'model is public' do
# let(:model) do
# build(
# described_class.model_name.param_key.to_sym,
# privacy: 'public'
# )
# end
describe '.public_content?' do
subject { model.public_content? }
it { is_expected.to be true }
end
end
end
# describe '.public_content?' do
# subject { model.public_content? }
# it { is_expected.to be true }
# end
# end
# end

View File

@ -1,71 +1,71 @@
require 'rails_helper'
# require 'rails_helper'
shared_examples_for 'content with an is_public scope' do
context 'when model is in a public universe' do
let(:universe) { create(:universe, privacy: 'public') }
# shared_examples_for 'content with an is_public scope' do
# context 'when model is in a public universe' do
# let(:universe) { create(:universe, privacy: 'public') }
context 'when model is private' do
let(:model) do
create(
described_class.model_name.param_key.to_sym,
universe: universe,
privacy: 'private'
)
end
# context 'when model is private' do
# let(:model) do
# create(
# described_class.model_name.param_key.to_sym,
# universe: universe,
# privacy: 'private'
# )
# end
describe '#is_public' do
subject { described_class.is_public }
it { is_expected.to include(model) }
end
end
# describe '#is_public' do
# subject { described_class.is_public }
# it { is_expected.to include(model) }
# end
# end
context 'when model is public' do
let(:model) do
create(
described_class.model_name.param_key.to_sym,
universe: universe,
privacy: 'public'
)
end
# context 'when model is public' do
# let(:model) do
# create(
# described_class.model_name.param_key.to_sym,
# universe: universe,
# privacy: 'public'
# )
# end
describe '#is_public' do
subject { described_class.is_public }
it { is_expected.to include(model) }
end
end
end
# describe '#is_public' do
# subject { described_class.is_public }
# it { is_expected.to include(model) }
# end
# end
# end
context 'when model is in a private universe' do
let(:universe) { build(:universe, privacy: 'private') }
# context 'when model is in a private universe' do
# let(:universe) { build(:universe, privacy: 'private') }
context 'when model is private' do
let(:model) do
create(
described_class.model_name.param_key.to_sym,
universe: universe,
privacy: 'private'
)
end
# context 'when model is private' do
# let(:model) do
# create(
# described_class.model_name.param_key.to_sym,
# universe: universe,
# privacy: 'private'
# )
# end
describe '#is_public' do
subject { described_class.is_public }
it { is_expected.to_not include(model) }
end
end
# describe '#is_public' do
# subject { described_class.is_public }
# it { is_expected.to_not include(model) }
# end
# end
context 'when model is public' do
let(:model) do
create(
described_class.model_name.param_key.to_sym,
universe: universe,
privacy: 'public'
)
end
# context 'when model is public' do
# let(:model) do
# create(
# described_class.model_name.param_key.to_sym,
# universe: universe,
# privacy: 'public'
# )
# end
describe '#is_public' do
subject { described_class.is_public }
it { is_expected.to include(model) }
end
end
end
end
# describe '#is_public' do
# subject { described_class.is_public }
# it { is_expected.to include(model) }
# end
# end
# end
# end

View File

@ -1,35 +1,35 @@
describe 'app/views/cards/serendipitous/_content_question.html.erb' do
# describe 'app/views/cards/serendipitous/_content_question.html.erb' do
let(:question) { 'What is my name?' }
let(:field) { :name }
let(:question_object) { { field: field, question: question } }
let(:content) { create(:character) }
# let(:question) { 'What is my name?' }
# let(:field) { :name }
# let(:question_object) { { field: field, question: question } }
# let(:content) { create(:character) }
shared_examples_for 'an empty serendipitous card' do
it 'renders nothing' do
render partial: 'cards/serendipitous/content_question', locals: { question: question_object, content: content }
expect(response).to match(/decided not to render serendipitous card/)
end
end
# shared_examples_for 'an empty serendipitous card' do
# it 'renders nothing' do
# render partial: 'cards/serendipitous/content_question', locals: { question: question_object, content: content }
# expect(response).to match(/decided not to render serendipitous card/)
# end
# end
# todo update these test with the new serendipitous logic
# context 'when question is an empty string' do
# let(:question_object) { '' }
# it_behaves_like 'an empty serendipitous card'
# end
#
# context 'when question[:field] is an empty string' do
# let(:question_object) { { field: '', question: question } }
# it_behaves_like 'an empty serendipitous card'
# end
#
# context 'when question[:question] is an empty string' do
# let(:question_object) { { field: field, question: '' } }
# it_behaves_like 'an empty serendipitous card'
# end
#
# context 'when content is an empty string' do
# let(:content) { '' }
# it_behaves_like 'an empty serendipitous card'
# end
end
# # todo update these test with the new serendipitous logic
# # context 'when question is an empty string' do
# # let(:question_object) { '' }
# # it_behaves_like 'an empty serendipitous card'
# # end
# #
# # context 'when question[:field] is an empty string' do
# # let(:question_object) { { field: '', question: question } }
# # it_behaves_like 'an empty serendipitous card'
# # end
# #
# # context 'when question[:question] is an empty string' do
# # let(:question_object) { { field: field, question: '' } }
# # it_behaves_like 'an empty serendipitous card'
# # end
# #
# # context 'when content is an empty string' do
# # let(:content) { '' }
# # it_behaves_like 'an empty serendipitous card'
# # end
# end