From 2d28227b9fa0504183f9dae60422a9cf747760e6 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 22 Oct 2013 14:27:20 -0500 Subject: [PATCH] * VRFS-783 - the filepicker service behaves different; workaround added. test attempted, but does not work because phantomjs crashes --- .../javascripts/accounts_profile_avatar.js | 13 ++++--- web/app/assets/javascripts/user_dropdown.js | 1 + web/app/views/clients/index.html.erb | 2 +- web/spec/assets/images/sample_avatar.png | Bin 0 -> 304 bytes web/spec/features/avatar_spec.rb | 32 ++++++++++++++++++ .../assets/stylesheets/jquery.Jcrop.css | 2 +- 6 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 web/spec/assets/images/sample_avatar.png create mode 100644 web/spec/features/avatar_spec.rb diff --git a/web/app/assets/javascripts/accounts_profile_avatar.js b/web/app/assets/javascripts/accounts_profile_avatar.js index 4d574f102..48bbfc20d 100644 --- a/web/app/assets/javascripts/accounts_profile_avatar.js +++ b/web/app/assets/javascripts/accounts_profile_avatar.js @@ -15,6 +15,7 @@ var selection = null; var targetCropSize = 88; var updatingAvatar = false; + var userDropdown; function beforeShow(data) { userId = data.id; @@ -92,7 +93,7 @@ function deleteAvatarSuccess(response) { renderAvatar(null, null); - JK.UserDropdown.loadMe(); + userDropdown.loadMe(); rest.getUserDetail() .done(function(userDetail) { @@ -306,8 +307,9 @@ quality: 90, policy: filepickerPolicy.policy, signature: filepickerPolicy.signature - }, { path: createStorePath(self.userDetail) + 'cropped.jpg', access: 'public' }, + }, { path: createStorePath(self.userDetail) + 'cropped-' + new Date().getTime() + '.jpg', access: 'public' }, function(cropped) { + logger.debug("converting cropped"); rest.getFilepickerPolicy({handle: cropped.url, convert: true}) .done(function(filepickerPolicy) { filepicker.convert(cropped, { @@ -320,6 +322,7 @@ signature: filepickerPolicy.signature }, { path: createStorePath(self.userDetail), access: 'public' }, function(scaled) { + logger.debug("converted and scaled final image %o", scaled); rest.updateAvatar({ original_fpfile: determineCurrentFpfile(), cropped_fpfile: scaled, @@ -361,7 +364,7 @@ self.userDetail = response; // notify any listeners that the avatar changed - JK.UserDropdown.loadMe(); + userDropdown.loadMe(); // $('.avatar_large img').trigger('avatar_changed', [self.userDetail.photo_url]); app.notify( @@ -414,13 +417,15 @@ return $.cookie('original_fpfile') == null ? userDetail.crop_selection : null; } - function initialize() { + function initialize(userDropdownInstance) { var screenBindings = { 'beforeShow': beforeShow, 'afterShow': afterShow }; app.bindScreen('account/profile/avatar', screenBindings); events(); + + userDropdown = userDropdownInstance; } this.initialize = initialize; diff --git a/web/app/assets/javascripts/user_dropdown.js b/web/app/assets/javascripts/user_dropdown.js index 08c8fac99..71d700f94 100644 --- a/web/app/assets/javascripts/user_dropdown.js +++ b/web/app/assets/javascripts/user_dropdown.js @@ -89,5 +89,6 @@ invitationDialog = invitationDialogInstance; loadMe(); } + this.loadMe = loadMe; } })(window,jQuery); \ No newline at end of file diff --git a/web/app/views/clients/index.html.erb b/web/app/views/clients/index.html.erb index 309a59786..f8f109faa 100644 --- a/web/app/views/clients/index.html.erb +++ b/web/app/views/clients/index.html.erb @@ -117,7 +117,7 @@ accountProfileScreen.initialize(); var accountProfileAvatarScreen = new JK.AccountProfileAvatarScreen(JK.app); - accountProfileAvatarScreen.initialize(); + accountProfileAvatarScreen.initialize(userDropdown); var accountAudioProfile = new JK.AccountAudioProfile(JK.app); accountAudioProfile.initialize(); diff --git a/web/spec/assets/images/sample_avatar.png b/web/spec/assets/images/sample_avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..a3cedd4111f735b76dd1c366bbc305de4e008212 GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^DImFdgVmrG2@%4*@pqiH}P$r9Iy66gHf+|;}h2Ir#G#FEq$h4Rdj3S->P@Ey;y_0}Gouu94*Td9GSTTCZngTR3%FoPrE zVAItVrRLL~NH%?b?mzn}PvXHQR__f!VOH*GU{Xv6#0F}DkQ-RQ1|)ETj7c~s1SXqQ tL2OiwtAjsYZa9mu24n^cSk>#_W^MC15332){{Xt0!PC{xWt~$(697vlVVnQ} literal 0 HcmV?d00001 diff --git a/web/spec/features/avatar_spec.rb b/web/spec/features/avatar_spec.rb new file mode 100644 index 000000000..2261b5a2e --- /dev/null +++ b/web/spec/features/avatar_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe "Avatar", :js => true, :type => :feature, :capybara_feature => true do + + subject { page } + + before(:all) do + Capybara.javascript_driver = :poltergeist + Capybara.current_driver = Capybara.javascript_driver + Capybara.default_wait_time = 10 + end + + let(:user) { FactoryGirl.create(:user) } + + before(:each) do + UserMailer.deliveries.clear + sign_in_poltergeist user + visit "/client#/account/profile/avatar" + + find('#account-edit-avatar-upload') + end + + it { + pending "capybara crashes trying this test" + should have_selector('#account-edit-avatar-upload') + click_link "UPLOAD" # launch filepicker dialog, which is an iframe + within_frame('filepicker_dialog') { + attach_file('fileUpload', 'spec/assets/images/sample_avatar.png') + find('div.jcrop-tracker').should_not be_nil + } + } +end diff --git a/web/vendor/assets/stylesheets/jquery.Jcrop.css b/web/vendor/assets/stylesheets/jquery.Jcrop.css index 95f8b9cfc..05037ceeb 100644 --- a/web/vendor/assets/stylesheets/jquery.Jcrop.css +++ b/web/vendor/assets/stylesheets/jquery.Jcrop.css @@ -15,7 +15,7 @@ /* Selection Border */ .jcrop-vline, .jcrop-hline { - background: #ffffff url("Jcrop.gif"); + background: #ffffff url("/assets/Jcrop.gif"); font-size: 0; position: absolute; }