Skip to content

Commit

Permalink
Merge pull request #1694 from scottsds/hills_recovered_test_branch
Browse files Browse the repository at this point in the history
Flesh out Archive Tests
  • Loading branch information
CristinaRO committed Jun 17, 2014
2 parents f1a5a3c + bb96d01 commit c75ab58
Show file tree
Hide file tree
Showing 51 changed files with 1,414 additions and 266 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -63,3 +63,11 @@ features/cassette_library/cucumber_tags/work_import_special_characters_auto_lati
features/cassette_library/cucumber_tags/work_import_special_characters_man_cp.yml
features/cassette_library/cucumber_tags/work_import_special_characters_man_latin.yml
features/cassette_library/cucumber_tags/import_lj_comm.yml

spec/results.html
spec/results
features_report.html
coverage

.simplecov
.rspec
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -28,6 +28,8 @@ before_script:
- cp config/redis-cucumber.conf.example config/redis-cucumber.conf
- cp config/redis.travis.example config/redis.yml
- curl -L https://gist.githubusercontent.com/scottsds/8fda6f6fbc66d3a2315e/raw/1d4b990f7922e388d6d7563b9e5cda7c97af18a7/gistfile1.sh | bash
after_script:
- bundle exec rake coveralls:push
notifications:
email:
recipients:
Expand All @@ -37,5 +39,5 @@ notifications:
irc:
channels:
- "irc.freenode.org#otw-dev"
on_success: always
on_success: change
on_failure: always
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -95,6 +95,9 @@ group :test do
gem "vcr", "~> 2.5.0"
gem 'delorean'
gem 'faker'
# Code coverage
gem 'simplecov', :require => false
gem 'email_spec'
end

group :test, :development do
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Expand Up @@ -94,6 +94,9 @@ GEM
docile (1.1.1)
domain_name (0.5.12)
unf (>= 0.0.5, < 1.0.0)
email_spec (1.5.0)
launchy (~> 2.1)
mail (~> 2.2)
erubis (2.7.0)
escape_utils (0.3.2)
ethon (0.6.2)
Expand Down Expand Up @@ -329,6 +332,7 @@ DEPENDENCIES
cucumber-rails
database_cleaner
delorean
email_spec
escape_utils
factory_girl
faker
Expand Down Expand Up @@ -359,6 +363,7 @@ DEPENDENCIES
rvm-capistrano
sanitize
shoulda
simplecov
timeliness
tire
typhoeus
Expand Down
4 changes: 4 additions & 0 deletions Rakefile
Expand Up @@ -7,3 +7,7 @@ require 'resque/tasks'

include Rake::DSL
Otwarchive::Application.load_tasks

require 'coveralls/rake/task'
Coveralls::RakeTask.new

11 changes: 1 addition & 10 deletions app/helpers/inbox_helper.rb
Expand Up @@ -14,14 +14,5 @@ def commentable_description_link(comment)
end

# get_commenter_pseud_or_name can be found in comments_helper

def inbox_reply_link(comment)
if comment.depth > ArchiveConfig.COMMENT_THREAD_MAX_DEPTH
fallback_url = url_for(comment_path(comment, :add_comment_reply_id => comment.id, :anchor => 'comment_' + comment.id.to_s))
else
fallback_url = fallback_url_for_comment(comment, {:add_comment_reply_id => comment.id})
end
link_to "Reply", {:url => reply_user_inbox_path(current_user, :comment_id => comment), :method => :get}, :remote => true, :href => fallback_url
end


end
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -471,7 +471,7 @@ def coauthored_works

### BETA INVITATIONS ###

#If a new user was invited, update the invitation
#If a new user has an invitation_token (meaning they were invited), the method sets the redeemed_at column for that invitation to Time.now
def mark_invitation_redeemed
unless self.invitation_token.blank?
invitation = Invitation.find_by_token(self.invitation_token)
Expand Down
3 changes: 1 addition & 2 deletions app/validators/url_active_validator.rb
Expand Up @@ -10,15 +10,14 @@ def validate_each(record,attribute,value)
return true if value.match("fanfiction.net")
inactive_url_msg = "could not be reached. If the URL is correct and the site is currently down, please try again later."
inactive_url_timeout = 10 # seconds

begin
status = Timeout::timeout(options[:timeout] || inactive_url_timeout) {
url = URI.parse(value)
response_code = Net::HTTP.start(url.host, url.port) {|http| http.head(url.path.blank? ? '/' : url.path).code}
active_status = %w(200 301 302)
active_status.include? response_code
}
rescue
rescue
status = false
end
record.errors[attribute] << (options[:message] || inactive_url_msg) unless status
Expand Down
1 change: 1 addition & 0 deletions config/cucumber.yml
Expand Up @@ -6,3 +6,4 @@ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@w
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
html_report: --format progress --format html --out=features/features_report.html
10 changes: 10 additions & 0 deletions factories/abuse_reports.rb
@@ -0,0 +1,10 @@
require 'faker'
FactoryGirl.define do
factory :abuse_report do
email {Faker::Internet.email}
url "http://archiveofourown.org/tags/2000%20AD%20(Comics)/works"
comment {Faker::Lorem.paragraph(1)}
category 11469
cc_me "0"
end
end
10 changes: 10 additions & 0 deletions factories/admin.rb
@@ -0,0 +1,10 @@
require 'faker'

FactoryGirl.define do
factory :admin do
login
password "password"
password_confirmation { |u| u.password }
email
end
end
9 changes: 9 additions & 0 deletions factories/admin_post.rb
@@ -0,0 +1,9 @@
require 'faker'

FactoryGirl.define do
factory :admin_post do
admin_id { FactoryGirl.create(:admin).id }
title "AdminPost Title"
content "AdminPost content long enough to pass validation"
end
end
10 changes: 10 additions & 0 deletions factories/bookmarks.rb
@@ -0,0 +1,10 @@
require 'faker'

FactoryGirl.define do
factory :bookmark do
bookmarkable_type "Work"
bookmarkable_id { FactoryGirl.create(:work).id }
pseud_id { FactoryGirl.create(:pseud).id }
end

end
19 changes: 19 additions & 0 deletions factories/challenges.rb
@@ -0,0 +1,19 @@
require 'faker'
FactoryGirl.define do
factory :challenge_assignment do
after(:build) do |assignment|
assignment.collection_id = FactoryGirl.create(:collection, :challenge => GiftExchange.new).id unless assignment.collection_id
assignment.request_signup = FactoryGirl.create(:challenge_signup, :collection_id => assignment.collection_id)
assignment.offer_signup = FactoryGirl.create(:challenge_signup, :collection_id => assignment.collection_id)
end
end

factory :challenge_signup do
after(:build) do |signup|
signup.pseud_id = FactoryGirl.create(:pseud).id unless signup.pseud_id
signup.collection_id = FactoryGirl.create(:collection, :challenge => GiftExchange.new).id unless signup.collection_id
signup.offers.build(pseud_id: signup.pseud_id, collection_id: signup.collection_id)
signup.requests.build(pseud_id: signup.pseud_id, collection_id: signup.collection_id)
end
end
end
8 changes: 8 additions & 0 deletions factories/chapters.rb
@@ -0,0 +1,8 @@
require 'faker'

FactoryGirl.define do
factory :chapter do
content "Awesome content!"
work
end
end
34 changes: 34 additions & 0 deletions factories/collections.rb
@@ -0,0 +1,34 @@
require 'faker'

FactoryGirl.define do

sequence(:collection_name) do |n|
"basic_collection_#{n}"
end

sequence(:collection_title) do |n|
"Basic Collection #{n}"
end

factory :collection_participant do
pseud
participant_role "Owner"
end

factory :collection_preference do |f|
collection
end

factory :collection_profile do |f|
collection
end

factory :collection do |f|
name {generate(:collection_name)}
title {generate(:collection_title)}

after(:build) do |collection|
collection.collection_participants.build(pseud_id: FactoryGirl.create(:pseud).id, participant_role: "Owner")
end
end
end
30 changes: 30 additions & 0 deletions factories/comments.rb
@@ -0,0 +1,30 @@
require 'faker'

FactoryGirl.define do
factory :comment do
name {Faker::Name.first_name}
content {Faker::Lorem.sentence(25)}
email {Faker::Internet.email}
commentable_type {"Work"}
commentable_id { FactoryGirl.create(:work).id }
pseud
end

factory :adminpost_comment, class: Comment do
name {Faker::Name.first_name}
content {Faker::Lorem.sentence(25)}
email {Faker::Internet.email}
commentable_type {"AdminPost"}
commentable_id { FactoryGirl.create(:admin_post).id }
pseud
end

factory :tag_comment, class: Comment do
name {Faker::Name.first_name}
content {Faker::Lorem.sentence(25)}
email {Faker::Internet.email}
commentable_type {"Tag"}
commentable_id { FactoryGirl.create(:fandom).id }
pseud
end
end
18 changes: 18 additions & 0 deletions factories/faq.rb
@@ -0,0 +1,18 @@
require 'faker'

FactoryGirl.define do

sequence(:faq_title) do |n|
"The #{n} FAQ"
end

sequence(:content) do |n|
"This is the #{n} FAQ"
end

factory :archive_faq do |f|
title {generate(:faq_title)}
content
end

end
10 changes: 10 additions & 0 deletions factories/feedback.rb
@@ -0,0 +1,10 @@
require 'faker'

FactoryGirl.define do
factory :feedback do
comment [Faker::Lorem.paragraph(1)]
email {Faker::Internet.email}
summary {Faker::Lorem.sentence(1)}
category 11483
end
end
13 changes: 13 additions & 0 deletions factories/invitations.rb
@@ -0,0 +1,13 @@
require 'faker'

FactoryGirl.define do

factory :invite_request do
email
end

factory :invitation do
invitee_email "default@email.com"
end

end
8 changes: 8 additions & 0 deletions factories/kudos.rb
@@ -0,0 +1,8 @@
require 'faker'

FactoryGirl.define do
factory :kudo do |f|
f.commentable_id { FactoryGirl.create(:work).id }
f.commentable_type "Work"
end
end
8 changes: 8 additions & 0 deletions factories/pseuds.rb
@@ -0,0 +1,8 @@
require 'faker'

FactoryGirl.define do
factory :pseud do
name { Faker::Lorem.characters(8) }
user
end
end
12 changes: 12 additions & 0 deletions factories/series.rb
@@ -0,0 +1,12 @@
require 'faker'

FactoryGirl.define do

sequence(:series_title) do |n|
"Awesome Series #{n}"
end

factory :series do
title {generate(:series_title)}
end
end
14 changes: 14 additions & 0 deletions factories/skins.rb
@@ -0,0 +1,14 @@
require 'faker'
FactoryGirl.define do

factory :private_work_skin, class: Skin do
author_id {FactoryGirl.create(:user).id}
title {Faker::Lorem.word}
type "WorkSkin"
public false

factory :public_work_skin do
public true
end
end
end
10 changes: 10 additions & 0 deletions factories/subscriptions.rb
@@ -0,0 +1,10 @@
require 'faker'

FactoryGirl.define do

factory :subscription do
subscribable_type "Series"
subscribable_id { FactoryGirl.create(:series).id }
user
end
end

0 comments on commit c75ab58

Please sign in to comment.