write cucumber test and add order_id on create
This commit is contained in:
parent
3c09756417
commit
28c9cfdfd4
9 changed files with 62 additions and 3 deletions
5
Gemfile
5
Gemfile
|
|
@ -253,6 +253,11 @@ group :test do
|
|||
gem "database_cleaner" , "1.4.1"
|
||||
gem "selenium-webdriver", "2.45.0"
|
||||
|
||||
source "https://rails-assets.org" do
|
||||
gem "rails-assets-jquery-simulate", "1.0.1"
|
||||
gem "rails-assets-jquery-simulate-ext", "1.3.0"
|
||||
end
|
||||
|
||||
# General helpers
|
||||
|
||||
gem "factory_girl_rails", "4.5.0"
|
||||
|
|
|
|||
|
|
@ -500,6 +500,9 @@ GEM
|
|||
rails-assets-jquery-idletimer (1.0.1)
|
||||
rails-assets-jquery-placeholder (2.1.1)
|
||||
rails-assets-jquery (>= 1.6)
|
||||
rails-assets-jquery-simulate (1.0.1)
|
||||
rails-assets-jquery-simulate-ext (1.3.0)
|
||||
rails-assets-jquery (>= 1.7.0)
|
||||
rails-assets-jquery-textchange (0.2.3)
|
||||
rails-assets-jquery
|
||||
rails-assets-jquery-ui (1.10.4)
|
||||
|
|
@ -773,6 +776,8 @@ DEPENDENCIES
|
|||
rails-assets-jquery (= 1.11.1)!
|
||||
rails-assets-jquery-idletimer (= 1.0.1)!
|
||||
rails-assets-jquery-placeholder (= 2.1.1)!
|
||||
rails-assets-jquery-simulate (= 1.0.1)!
|
||||
rails-assets-jquery-simulate-ext (= 1.3.0)!
|
||||
rails-assets-jquery-textchange (= 0.2.3)!
|
||||
rails-assets-markdown-it (= 4.2.0)!
|
||||
rails-assets-markdown-it--markdown-it-for-inline (= 0.1.0)!
|
||||
|
|
|
|||
|
|
@ -81,8 +81,11 @@ app.pages.Contacts = Backbone.View.extend({
|
|||
$("#aspect_nav .nav").sortable({
|
||||
items: "li.aspect[data-aspect-id]",
|
||||
update: function() {
|
||||
$("#aspect_nav .ui-sortable").removeClass("synced");
|
||||
var data = JSON.stringify({ ordered_aspect_ids: $(this).sortable("toArray", { attribute: "data-aspect-id" }) });
|
||||
$.ajax("/aspects/order", { type: "put", dataType: "text", contentType: "application/json", data: data });
|
||||
$.ajax(Routes.order_aspects_path(),
|
||||
{ type: "put", dataType: "text", contentType: "application/json", data: data })
|
||||
.done(function() { $("#aspect_nav .ui-sortable").addClass("synced"); });
|
||||
},
|
||||
revert: true,
|
||||
helper: "clone"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ class Aspect < ActiveRecord::Base
|
|||
name.strip!
|
||||
end
|
||||
|
||||
before_create do
|
||||
self.order_id ||= Aspect.where(user_id: user_id).maximum(:order_id || 0).to_i + 1
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#aspect_nav
|
||||
%ul.nav.nav-tabs.nav-stacked
|
||||
%ul.nav.nav-tabs.nav-stacked.synced
|
||||
%li.all_contacts{:class => ("active" if params["set"] == "all")}
|
||||
%a{:href => contacts_path(:set => "all")}
|
||||
= t('contacts.index.all_contacts')
|
||||
|
|
|
|||
|
|
@ -63,10 +63,12 @@ Diaspora::Application.routes.draw do
|
|||
get "commented" => "streams#commented", :as => "commented_stream"
|
||||
get "aspects" => "streams#aspects", :as => "aspects_stream"
|
||||
|
||||
put "aspects/order" => "aspects#update_order"
|
||||
resources :aspects do
|
||||
put :toggle_contact_visibility
|
||||
put :toggle_chat_privilege
|
||||
collection do
|
||||
put "order" => :update_order
|
||||
end
|
||||
end
|
||||
|
||||
get 'bookmarklet' => 'status_messages#bookmarklet'
|
||||
|
|
|
|||
|
|
@ -75,3 +75,13 @@ Feature: User manages contacts
|
|||
And I click on my name in the header
|
||||
When I follow "Contacts"
|
||||
Then I should not see "Community spotlight" within ".span9"
|
||||
|
||||
Scenario: sorting the aspects
|
||||
Given I am signed in
|
||||
And I have an aspect called "People"
|
||||
And I have an aspect called "Cat People"
|
||||
When I am on the contacts page
|
||||
And I drag "Cat People" up 40 pixels
|
||||
And I go to the contacts page
|
||||
Then I should see "Cat People" as 2. aspect
|
||||
And I should see "People" as 3. aspect
|
||||
|
|
|
|||
|
|
@ -88,6 +88,25 @@ When /^(.*) in the aspect creation modal$/ do |action|
|
|||
end
|
||||
end
|
||||
|
||||
When /^I drag "([^"]*)" (up|down) (\d+) pixels?$/ do |aspect_name, direction, distance|
|
||||
distance = distance.to_i * -1 if direction == "up"
|
||||
page.execute_script %{
|
||||
function drag() {
|
||||
$("li.aspect:contains('#{aspect_name}')")
|
||||
.simulate("drag-n-drop", { dy: #{distance}, interpolation: { stepWidth: 10, stepDelay: 5 } });
|
||||
}
|
||||
function loadScripts() {
|
||||
$.getScript("/assets/jquery-simulate/jquery.simulate.js", function(){
|
||||
$.getScript("/assets/jquery-simulate-ext/src/jquery.simulate.ext.js", function(){
|
||||
$.getScript("/assets/jquery-simulate-ext/src/jquery.simulate.drag-n-drop.js", drag);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!$.simulate) { loadScripts(); } else { drag(); }
|
||||
}
|
||||
expect(find("#aspect_nav")).to have_css ".synced"
|
||||
end
|
||||
|
||||
And /^I toggle the aspect "([^"]*)"$/ do |name|
|
||||
toggle_aspect(name)
|
||||
end
|
||||
|
|
@ -109,3 +128,7 @@ end
|
|||
Then /^the aspect dropdown should be visible$/ do
|
||||
aspect_dropdown_visible?
|
||||
end
|
||||
|
||||
Then /^I should see "([^"]*)" as (\d+). aspect$/ do |aspect_name, position|
|
||||
expect(find("#aspect_nav li:nth-child(#{position.to_i + 2})")).to have_text aspect_name
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,6 +39,13 @@ describe Aspect, :type => :model do
|
|||
it 'has a contacts_visible? method' do
|
||||
expect(alice.aspects.first.contacts_visible?).to be true
|
||||
end
|
||||
|
||||
it "sets an order_id" do
|
||||
aspect_2 = alice.aspects.create(name: "People")
|
||||
expect(aspect_2.order_id).to eq(2)
|
||||
aspect_3 = alice.aspects.create(name: "Cat People")
|
||||
expect(aspect_3.order_id).to eq(3)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue