diff --git a/.gitignore b/.gitignore
index 703cf4cd4..06d209305 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,4 @@ target
vendor/bundle
public/assets
public/uploads
+/log/*.out
diff --git a/Gemfile b/Gemfile
index 659b40027..200185368 100644
--- a/Gemfile
+++ b/Gemfile
@@ -78,7 +78,7 @@ else
gem "capybara-webkit"
end
gem 'capybara-screenshot'
- gem 'cucumber-rails' #, '1.3.0', :require => false
+ gem 'cucumber-rails', :require => false #, '1.3.0', :require => false
gem 'factory_girl_rails', '4.1.0'
gem 'database_cleaner', '0.7.0'
gem 'guard-spork', '0.3.2'
diff --git a/app/assets/javascripts/header.js b/app/assets/javascripts/header.js
index 0e7f45135..0f45ae62a 100644
--- a/app/assets/javascripts/header.js
+++ b/app/assets/javascripts/header.js
@@ -148,7 +148,6 @@
userMe = r;
// TODO - Setting global variable for local user.
context.JK.userMe = r;
- updateAccountForms();
updateHeader();
}).fail(app.ajaxError);
}
@@ -160,26 +159,6 @@
$('#header-avatar').attr('src', photoUrl);
}
- function updateAccountForms() {
- var idTemplate = $('#template-identity-summary').html();
- var idHtml = context.JK.fillTemplate(idTemplate, userMe);
- $('#identity-summary').html(idHtml);
- // TODO:
- // Make a thing that puts a JSON object into a form
- // and fill the profile part of the form from the JSON.
- // Short-term thing for now:
- $('#account-identity-form input[name="email"]').val(userMe.email);
-
- // Profile form
- $('#account-profile-form input[name="name"]').val(userMe.name);
- if ("instruments" in userMe) {
- $.each(userMe.instruments, function() {
- addInstrument(this.description, this.id);
- setProficiency(this.id, this.proficiency_level);
- });
- }
- }
-
this.initialize = function() {
events();
diff --git a/app/assets/javascripts/utils.js b/app/assets/javascripts/utils.js
index bcb8bba70..37bc68c17 100644
--- a/app/assets/javascripts/utils.js
+++ b/app/assets/javascripts/utils.js
@@ -33,6 +33,9 @@
// _fillTemplate(template, vals);
// --> "Hey Jon"
context.JK.fillTemplate = function(template, vals) {
+ if(template == null) {
+ console.log("vals " + JSON.stringify(vals))
+ }
for(var val in vals)
template=template.replace(new RegExp('{'+val+'}','g'), vals[val]);
return template;
diff --git a/app/views/clients/_account.html.erb b/app/views/clients/_account.html.erb
index 4b9d5cb75..789614883 100644
--- a/app/views/clients/_account.html.erb
+++ b/app/views/clients/_account.html.erb
@@ -57,7 +57,7 @@
-

+
Name:{name}
Location:{location}
Instruments: {instruments}
diff --git a/config/environments/test.rb b/config/environments/test.rb
index fa101cf29..af5296ce3 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -43,14 +43,9 @@ SampleApp::Application.configure do
# For testing omniauth
OmniAuth.config.test_mode = true
- TEST_CONNECT_STATES = false
- if defined?(TEST_CONNECT_STATES) && TEST_CONNECT_STATES
- TEST_CONNECT_STATE_JS_LOG_PREFIX = '*** ASSERT'
- TEST_CONNECT_STATE_JS_CONSOLE = '/tmp/jam_connect_js.out'
- config.websocket_gateway_enable = true
- else
- config.websocket_gateway_enable = false
- end
+ config.websocket_gateway_enable = true
+ config.websocket_gateway_port = 6769
+ config.websocket_gateway_uri = "ws://localhost:#{config.websocket_gateway_port}/websocket"
# this is totally awful and silly; the reason this exists is so that if you upload an artifact
# through jam-admin, then jam-web can point users at it. I think 99% of devs won't even see or care about this config, and 0% of users
diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb
index 32df598d1..ff9be4fcc 100644
--- a/spec/features/account_spec.rb
+++ b/spec/features/account_spec.rb
@@ -2,7 +2,6 @@ require 'spec_helper'
describe "Account", :js => true, :type => :feature, :capybara_feature => true do
-=begin
subject { page }
before(:all) do
@@ -14,13 +13,62 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do
UserMailer.deliveries.clear
sign_in_poltergeist user
visit "/client#/account"
-
- puts page.html
end
let(:user) { FactoryGirl.create(:user) }
it { should have_selector('h1', text: 'my account') }
-=end
+
+ describe "identity" do
+ before(:each) do
+ click_link "account-edit-identity-link"
+ end
+
+ it { should have_selector('h2', text: 'identity:' ) }
+ it { should have_selector('form#account-edit-email-form th', text: 'Update your email address:') }
+ it { should have_selector('form#account-edit-password-form th', text: 'Update your password:') }
+
+ describe "update email" do
+
+ before(:each) do
+ fill_in "account_update_email", with: "junk@jamkazam.com"
+ # TODO: poltergeist doesn't support window.prompt, but we are changing this soon
+ #prompt = page.driver.browser.switch_to.alert
+ #prompt.send_keys(user.password)
+ #prompt.accept
+ end
+
+ #it { should have_selector('h1', text: 'my account') }
+ end
+
+ describe "update password" do
+
+ describe "successfully" do
+
+ before(:each) do
+ fill_in "current_password", with: user.password
+ fill_in "password", with: user.password
+ fill_in "password_confirmation", with: user.password
+ click_link "account-edit-password-submit"
+ end
+
+ it { should have_selector('h1', text: 'my account') }
+ end
+
+ describe "unsuccessfully" do
+
+ before(:each) do
+ click_link "account-edit-password-submit"
+ end
+
+ it { should have_selector('h2', text: 'identity:') }
+ it { should have_selector('div.field.error input[name=current_password] ~ ul li', text: "can't be blank") }
+ it { should have_selector('div.field.error input[name=password] ~ ul li', text: "is too short (minimum is 6 characters)") }
+ it { should have_selector('div.field.error input[name=password_confirmation] ~ ul li', text: "can't be blank") }
+ end
+
+ end
+
+ end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 75655b4f1..f7cfb1b85 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -25,7 +25,6 @@ include JamRuby
# put ActionMailer into test mode
ActionMailer::Base.delivery_method = :test
-
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
@@ -35,11 +34,12 @@ Spork.prefork do
require 'rspec/rails'
require 'rspec/autorun'
+
require 'capybara'
require 'capybara/rspec'
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
- Capybara::Poltergeist::Driver.new(app, { phantomjs_logger: 'log/phantomjs.out' })
+ Capybara::Poltergeist::Driver.new(app, { debug: false, phantomjs_logger: File.open('log/phantomjs.out', 'w') })
end
Capybara.javascript_driver = :poltergeist
@@ -80,16 +80,41 @@ Spork.prefork do
# 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.
- if defined?(TEST_CONNECT_STATES) && TEST_CONNECT_STATES
- config.use_transactional_fixtures = false
- else
- config.use_transactional_fixtures = true
- end
+ config.use_transactional_fixtures = false
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
+
+ config.before(:suite) do
+ DatabaseCleaner.clean_with(:truncation, {:except => %w[instruments genres] })
+ end
+
+ config.before(:each) do
+ # DatabaseCleaner.strategy = :transaction
+ DatabaseCleaner.strategy = :truncation, {:except => %w[instruments genres] }
+ end
+
+ config.before(:each, :js => true) do
+ DatabaseCleaner.strategy = :truncation, {:except => %w[instruments genres] }
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.start
+ end
+
+ config.after(:each) do
+ if example.metadata[:js]
+ sleep 0.2 # ugh. necessary though otherwise intermittent failures: http://stackoverflow.com/questions/14265983/upgrading-capybara-from-1-0-1-to-1-1-4-makes-database-cleaner-break-my-specs
+ end
+ DatabaseCleaner.clean
+ end
+
+
+ config.include Rails.application.routes.url_helpers
+ config.include Capybara::DSL
+
end
end
diff --git a/spec/support/utilities.rb b/spec/support/utilities.rb
index 12449e1a5..51a5b3bb3 100644
--- a/spec/support/utilities.rb
+++ b/spec/support/utilities.rb
@@ -19,4 +19,6 @@ def sign_in_poltergeist(user)
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "SIGN IN"
+
+ page.driver.set_cookie(:remember_token, user.remember_token)
end
\ No newline at end of file