Merge pull request #289 from openSUSE/review_140704_update_rails_and_replace_webkit_with_poltergeist

[Review] Request from 'kalabiyau' @ 'openSUSE/osem/review_140704_update_rails_and_replace_webkit_with_poltergeist'
This commit is contained in:
Artem Chernikov 2014-07-07 15:07:23 +02:00
commit 2ee621a9b2
20 changed files with 159 additions and 104 deletions

View file

@ -1,3 +0,0 @@
LineLength:
Description: 'Limit lines to 100 characters.'
Max: 100

View file

@ -1,6 +1,8 @@
language: ruby
rvm:
- 2.1.1
before_install:
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
branches:
only:
- master
@ -8,9 +10,6 @@ notifications:
email:
on_success: change
on_failure: change
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
before_script:
- cp config/database.yml.example config/database.yml
- cp config/config.yml.example config/config.yml

View file

@ -11,8 +11,10 @@ In particular, this community seeks the following types of contributions:
* Prerequisites: familiarity with [GitHub Pull Requests](https://help.github.com/articles/using-pull-requests) and issues.
* Fork the repository and make a pull-request with your changes
* Make sure that the test suite passes (we have [travis](https://travis-ci.org/openSUSE/osem) enabled) before you request a pull and that you comply to our ruby styleguide (we make use of [hound-ci](https://houndci.com/)).
* Please make sure to mind what travis and hound tell you! :-)
* One of the OSEM maintainers will review your pull-request
* Please make sure to mind what travis tell you! :-)
* Please increase code coverage by your pull request (coveralls or simplecov locally will give you insight)
* One of the OSEM maintainers will review your pull-request
* If you are already a contributor (means you're in the [group osem-committers](https://github.com/orgs/openSUSE/teams/osem-committers)) and you get a positive review, you can merge your pull-request yourself
* If you are not a contributor already please request a merge via the pull-request comments
* Run rubocop locally for fixes according to HoundCI comments
@ -28,4 +30,5 @@ admins](https://github.com/orgs/openSUSE/teams/osem-admins) know!
GitHub issues are the primary way for communicating about specific proposed
changes to this project. If you have other questions feel free to subscribe to
the [opensuse-web@opensuse.org](http://lists.opensuse.org/opensuse-web/)
mailinglist, all OSEM contributors are on that list!
mailinglist, all OSEM contributors are on that list! Additionally you can use #osem channel
on freenode IRC.

27
Gemfile
View file

@ -67,8 +67,6 @@ gem 'axlsx_rails'
gem 'd3_rails'
gem 'chart-js-rails'
# We use coveralls for measuring test coverage
gem 'coveralls', require: false
# Use a self-hosted errbit with the old notifier
gem 'hoptoad_notifier', '~> 2.3'
@ -84,15 +82,8 @@ gem 'font-awesome-rails'
#Use Redcarpet for Markdown in description
gem 'redcarpet'
# Use rspec and capybara as testing framework
group :development, :test do
gem 'rspec', '>= 3.0.0.beta'
gem 'rspec-rails', '>= 3.0.0.beta'
gem 'capybara'
gem 'database_cleaner'
gem 'capybara-webkit'
gem 'shoulda'
end
# Rubyracer is JavaScript Runtime of choice
gem 'therubyracer'
# FIXME: We should use http://weblog.rubyonrails.org/2012/3/21/strong-parameters/
gem 'protected_attributes'
@ -121,3 +112,17 @@ group :development do
# Use letter_opener to open mails in development
gem 'letter_opener'
end
# Use rspec and capybara as testing framework
group :test do
# We use coveralls for measuring test coverage
gem 'coveralls', require: false
gem 'rspec-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'poltergeist'
# Set of rails validations matchers to describe models
gem 'shoulda'
# Extracted from RSpec 3 stub_model and mock_model
gem 'rspec-activemodel-mocks'
end

View file

@ -68,9 +68,6 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.1.1)
capybara (~> 2.0, >= 2.0.2)
json
celluloid (0.15.2)
timers (~> 1.1.0)
celluloid-io (0.15.0)
@ -80,6 +77,7 @@ GEM
railties (> 3.1)
climate_control (0.0.3)
activesupport (>= 3.0)
cliver (0.3.2)
cocaine (0.5.4)
climate_control (>= 0.0.3, < 1.0)
cocoon (1.2.6)
@ -99,7 +97,7 @@ GEM
thor
d3_rails (3.4.6)
railties (>= 3.1.0)
database_cleaner (1.2.0)
database_cleaner (1.3.0)
devise (3.2.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@ -166,6 +164,7 @@ GEM
addressable (~> 2.3)
letter_opener (1.2.0)
launchy (~> 2.2)
libv8 (3.16.14.3)
listen (2.7.2)
celluloid (>= 0.15.2)
celluloid-io (>= 0.15.0)
@ -222,6 +221,11 @@ GEM
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
pdf-core (0.2.5)
poltergeist (1.5.1)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
polyglot (0.3.5)
powerpack (0.0.9)
prawn (1.0.0)
@ -274,34 +278,35 @@ GEM
rdoc (~> 4.0)
yajl-ruby (~> 1.1)
redcarpet (3.1.2)
ref (1.0.5)
referer-parser (0.2.1)
request_store (1.0.6)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (3.0.0.beta2)
rspec-core (= 3.0.0.beta2)
rspec-expectations (= 3.0.0.beta2)
rspec-mocks (= 3.0.0.beta2)
rspec-collection_matchers (0.0.4)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.0.0.beta2)
rspec-support (= 3.0.0.beta2)
rspec-expectations (3.0.0.beta2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (= 3.0.0.beta2)
rspec-mocks (3.0.0.beta2)
rspec-support (= 3.0.0.beta2)
rspec-rails (3.0.0.beta2)
actionpack (>= 3.0)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-activemodel-mocks (1.0.1)
activemodel (>= 3.0)
activesupport (>= 3.0)
rspec-mocks (>= 2.99, < 4.0)
rspec-core (3.0.2)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.2)
rspec-support (~> 3.0.0)
rspec-rails (3.0.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-collection_matchers
rspec-core (= 3.0.0.beta2)
rspec-expectations (= 3.0.0.beta2)
rspec-mocks (= 3.0.0.beta2)
rspec-support (= 3.0.0.beta2)
rspec-support (3.0.0.beta2)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
rubocop (0.22.0)
json (>= 1.7.7, < 2)
parser (~> 2.1.9)
@ -344,6 +349,9 @@ GEM
sqlite3 (1.3.9)
term-ansicolor (1.3.0)
tins (~> 1.0)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
@ -365,6 +373,7 @@ GEM
uuidtools (2.1.4)
warden (1.2.3)
rack (>= 1.0)
websocket-driver (0.3.3)
xpath (2.0.0)
nokogiri (~> 1.3)
yajl-ruby (1.2.0)
@ -382,7 +391,6 @@ DEPENDENCIES
bootstrap-sass
cancan
capybara
capybara-webkit
chart-js-rails
cocoon
coveralls
@ -408,6 +416,7 @@ DEPENDENCIES
omniauth-openid
paper_trail
paperclip
poltergeist
prawn_rails
protected_attributes
quiet_assets
@ -415,13 +424,14 @@ DEPENDENCIES
rails-observers
rdoc-generator-fivefish
redcarpet
rspec (>= 3.0.0.beta)
rspec-rails (>= 3.0.0.beta)
rspec-activemodel-mocks
rspec-rails
rubocop
sass-rails (>= 4.0.2)
shoulda
spring-commands-rspec
sqlite3
therubyracer
transitions
turbolinks
uglifier (>= 1.3.0)

View file

@ -86,3 +86,10 @@ bundle exec guard
```
This uses [spring](https://github.com/rails/spring) to provide a
[fast feedback loop for the red/green cycle](http://bitzesty.com/blog/2013/05/enable-tdd-with-faster-ruby-on-rails-stack-reloading/).
# Communication
GitHub issues are the primary way for communicating about specific proposed
changes to this project. If you have other questions feel free to subscribe to
the [opensuse-web@opensuse.org](http://lists.opensuse.org/opensuse-web/)
mailinglist, all OSEM contributors are on that list! Additionally you can use #osem channel
on freenode IRC.

View file

@ -180,10 +180,8 @@ function word_count(text, divId, maxcount) {
$('#' + divId).text(r);
if (r > maxcount) {
console.log("R is greater than maxcount");
$('#' + divId).css('color', 'red');
} else {
console.log("R is less than maxcount");
$('#' + divId).css('color', '#333');
}
};

View file

@ -115,7 +115,6 @@ class Conference < ActiveRecord::Base
return nil if user.nil?
if registrations.where(user_id: user.id).count == 0
logger.debug("User #{user.email} isn't registered to self.title")
return false
else
return true

View file

@ -40,4 +40,9 @@ Osem::Application.configure do
# Do not perform deliveries on test
config.action_mailer.perform_deliveries = false
config.after_initialize do
ActiveRecord::Base.logger = nil
end
end

View file

@ -9,7 +9,8 @@ class MigrateDataPersonToUser < ActiveRecord::Migration
def change
TempPerson.all.each do |p|
user = TempUser.find(p.user_id)
user = TempUser.find_by(id: p.user_id)
next unless user
if p.public_name.empty?
user.name = p.email
else

View file

@ -1,7 +1,6 @@
class CreateVisits < ActiveRecord::Migration
def change
create_table :visits, id: false do |t|
t.uuid :id, primary_key: true
create_table :visits do |t|
t.uuid :visitor_id
# the rest are recommended but optional

View file

@ -1,20 +1,17 @@
class CreateAhoyEvents < ActiveRecord::Migration
def change
create_table :ahoy_events, id: false do |t|
t.uuid :id, primary_key: true
create_table :ahoy_events do |t|
t.uuid :visit_id
# user
t.integer :user_id
# add t.string :user_type if polymorphic
t.string :name
t.text :properties
t.timestamp :time
end
add_index :ahoy_events, [:visit_id]
add_index :ahoy_events, [:user_id]
add_index :ahoy_events, [:time]
add_index :ahoy_events, :visit_id
add_index :ahoy_events, :user_id
add_index :ahoy_events, :time
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140626123837) do
ActiveRecord::Schema.define(version: 20140627165718) do
create_table "ahoy_events", force: true do |t|
t.uuid "visit_id"
@ -21,7 +21,6 @@ ActiveRecord::Schema.define(version: 20140626123837) do
t.datetime "time"
end
# add_index "ahoy_events", ["id"], name: "sqlite_autoindex_ahoy_events_1", unique: true
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time"
add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id"
add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id"
@ -113,13 +112,13 @@ ActiveRecord::Schema.define(version: 20140626123837) do
t.string "facebook_url"
t.string "google_url"
t.text "lodging_description"
t.boolean "make_conference_public", default: false
t.boolean "include_registrations_in_splash", default: false
t.boolean "include_sponsors_in_splash", default: false
t.boolean "include_tracks_in_splash", default: false
t.boolean "include_tickets_in_splash", default: false
t.boolean "include_social_media_in_splash", default: false
t.boolean "include_program_in_splash", default: false
t.boolean "make_conference_public", default: false
t.string "banner_photo_file_name"
t.string "banner_photo_content_type"
t.integer "banner_photo_file_size"
@ -305,8 +304,8 @@ ActiveRecord::Schema.define(version: 20140626123837) do
t.text "other_special_needs"
t.boolean "attended", default: false
t.boolean "volunteer"
t.integer "week"
t.integer "user_id"
t.integer "week"
end
create_table "registrations_social_events", id: false, force: true do |t|
@ -503,7 +502,6 @@ ActiveRecord::Schema.define(version: 20140626123837) do
t.datetime "started_at"
end
# add_index "visits", ["id"], name: "sqlite_autoindex_visits_1", unique: true
add_index "visits", ["user_id"], name: "index_visits_on_user_id"
create_table "votes", force: true do |t|

View file

@ -13,11 +13,15 @@ describe Admin::ConferenceController do
let(:participant) { create(:participant) }
shared_examples 'access as administration or organizer' do
describe 'PATCH #update' do
context 'valid attributes' do
it 'locates the requested conference' do
patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con')
expect(assigns(:conference)).to eq(conference)
end
@ -192,7 +196,7 @@ describe Admin::ConferenceController do
describe 'administrator access' do
before(:each) do
before do
sign_in(admin)
end

View file

@ -12,6 +12,7 @@ feature Sponsor do
conference = create(:conference)
conference.sponsorship_levels << create(:sponsorship_level, conference: conference)
sign_in create(user)
visit admin_conference_sponsors_path(
conference_id: conference.short_title)
# Add sponsors
@ -36,6 +37,7 @@ feature Sponsor do
find(:css, "select[id^='conference_sponsors_attributes_']"\
"[id$='_sponsorship_level_id']").
find(:option, 'Platin').select_option
click_button 'Update Conference'
expect(flash).to eq('Sponsorships were successfully updated.')
@ -55,7 +57,7 @@ feature Sponsor do
value).to eq('http://www.example.com')
expect(find('div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(5) select:nth-of-type(1)').
' div:nth-of-type(5) select:nth-of-type(1)').find('option[selected]').
text).to eq('Platin')
# Remove sponsor

View file

@ -103,9 +103,10 @@ feature Conference do
expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(2) textarea').
value).to eq('Example Description')
expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(3) select:nth-of-type(1)').
text).to eq("#{Date.today.strftime}")
' div:nth-of-type(3) select:nth-of-type(1)').find('option[selected]').
text).to eq(Date.today.strftime)
# Remove vposition
click_link 'Remove vposition'

View file

@ -1,10 +1,24 @@
require 'coveralls'
Coveralls.wear!('rails')
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'simplecov'
if ENV['TRAVIS']
require 'coveralls'
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
Coveralls.wear!('rails')
else
SimpleCov.start 'rails'
end
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
# To avoid confusion on missed migrations - use Rails 4 checker to ensure
# all migrations applied
ActiveRecord::Migration.maintain_test_schema!
# Add poltergeist to use it as JS driver
require 'capybara/poltergeist'
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
@ -24,9 +38,6 @@ RSpec.configure do |config|
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
@ -38,33 +49,44 @@ RSpec.configure do |config|
# --seed 1234
config.order = 'random'
# Include factory_girls syntax
# Setting up DB cleaning to maintain empty rows
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
# poltergeist as a underlying mech for Capybara
Capybara.javascript_driver = :poltergeist
# Includes helpers and connect them to specific types of tests
config.include FactoryGirl::Syntax::Methods
# Enables devise sign_in function
config.include OmniauthMacros
config.include Devise::TestHelpers, type: :controller
# Enables devise sign_in function
config.include Devise::TestHelpers, type: :view
# Use capybara-webkit as default javascript driver
Capybara.javascript_driver = :webkit
# Includes support/login_macros for feature tests
config.include LoginMacros, type: :feature
# Includes omniauth macro
config.include(OmniauthMacros)
# Includes support/flash for feature tests
config.include Flash, type: :feature
config.include Sidebar, type: :view
config.include Devise::TestHelpers, type: :view
# As we start from scratch in April 2014, let's forbid the old :should syntax
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.use_transactional_fixtures = true
# Reuse rspec as mocking framework
config.mock_framework = :rspec
# Types of tests (controller, feature, model) will
# be inferred from subfolder name
config.infer_spec_type_from_file_location!
end
OmniAuth.config.test_mode = true

View file

@ -0,0 +1,10 @@
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

View file

@ -1,17 +1,14 @@
module LoginMacros
include Warden::Test::Helpers
Warden.test_mode!
def sign_in(user)
visit new_user_session_path
fill_in 'user_email', with: user.email
fill_in 'user_password', with: user.password
find(:xpath, "//div[@id='content']//button[@type='submit']").click
expect(page.has_content?('Signed in successfully')).to be true
login_as(user, :scope => :user)
end
def sign_out
Capybara.current_session.driver.browser.clear_cookies
visit root_path
expect(page.has_content?('Sign In')).to be true
logout(:user)
end
end

View file

@ -1,4 +1,5 @@
require 'spec_helper'
describe 'admin/callforpapers/show' do
it 'renders callforpapers details' do
@ -8,8 +9,8 @@ describe 'admin/callforpapers/show' do
end_date: Date.today + 7.days,
description: 'Lorem Ipsum Dolsum')
render
expect(rendered).to include("#{Date.today}")
expect(rendered).to include("#{Date.today + 7.days}")
expect(rendered).to include(Date.today.strftime('%Y-%m-%d'))
expect(rendered).to include(7.days.from_now.strftime('%Y-%m-%d'))
expect(rendered).to include('Lorem Ipsum Dolsum')
end