spec/requests/account_users_spec.rb in iugusdk-1.0.0.alpha.2 vs spec/requests/account_users_spec.rb in iugusdk-1.0.0.alpha.3
- old
+ new
@@ -1,10 +1,11 @@
require 'spec_helper'
describe "Account Users Requests" do
before(:each) do
IuguSDK::enable_social_login = true
+ IuguSDK::enable_multiple_users_per_account = true
@user = Fabricate(:user)
visit '/account/auth/facebook'
@current_user = User.last
@account = Account.last
end
@@ -12,11 +13,11 @@
context "index" do
context "when current_user is account owner" do
before(:each) do
- @account.account_users << AccountUser.create(:user_id => @user.id)
+ @account.account_users << AccountUser.create(:user => @user)
@account.account_users.last.set_roles(["user"])
@account_user = AccountUser.find_by_account_id_and_user_id(Account.last.id, User.last.id)
@account_user.set_roles(["owner"])
visit account_users_index_path(:account_id => User.last.accounts.first.id)
end
@@ -29,11 +30,11 @@
end
context "when current_user is account admin" do
before(:each) do
- @account.account_users << AccountUser.create(:user_id => @user.id)
+ @account.account_users << AccountUser.create(:user => @user)
@account.account_users.last.set_roles(["user"])
@account_user = AccountUser.find_by_account_id_and_user_id(Account.last.id, User.last.id)
@account_user.set_roles(["admin"])
visit account_users_index_path(:account_id => User.last.accounts.first.id)
end
@@ -47,11 +48,11 @@
context "when current_user is not owner nor admin" do
before(:each) do
@account.account_users << Fabricate(:account_user) { user Fabricate(:user) { email "notowner@account.test" } }
- @account.account_users << AccountUser.create(:user_id => @user.id)
+ @account.account_users << AccountUser.create(:user => @user)
@account.account_users.last.set_roles(["user"])
@account_user = AccountUser.find_by_account_id_and_user_id(@account.id, @current_user.id)
@account_user.set_roles(["user"])
visit account_users_index_path(:account_id => @current_user.accounts.first.id)
end
@@ -63,11 +64,11 @@
end
context "when current_user and account_user are owners" do
before(:each) do
- @account.account_users << AccountUser.create(:user_id => @user.id)
+ @account.account_users << AccountUser.create(:user => @user)
@account.account_users.last.set_roles(["owner"])
@account_user = AccountUser.find_by_account_id_and_user_id(Account.last.id, @current_user.id)
@account_user.set_roles(["owner"])
visit account_users_index_path(:account_id => @current_user.accounts.first.id)
end
@@ -95,10 +96,10 @@
end
context "destroy" do
before(:each) do
- @account.account_users << AccountUser.create(:user_id => @user.id)
+ @account.account_users << AccountUser.create(:user => @user)
@account.account_users.last.set_roles(["user"])
@account_user = AccountUser.find_by_account_id_and_user_id(Account.last.id, User.last.id)
@account_user.set_roles(["owner"])
visit account_users_index_path(:account_id => User.last.accounts.first.id)
end