create view directory per @Ducz0r 's request

This commit is contained in:
zmagod 2017-11-09 10:06:53 +01:00
parent 9eac014f1a
commit e0b6683a44
8 changed files with 25 additions and 21 deletions

View file

@ -8,7 +8,7 @@ import type { Dispatch } from "redux-thunk";
import {
getTeams,
changeCurrentTeam,
fetchCurrentTeam
getCurrentTeam as fetchCurrentTeam
} from "../../services/api/teams_api";
import { GET_LIST_OF_TEAMS, SET_CURRENT_TEAM } from "../../config/action_types";

View file

@ -36,5 +36,5 @@ export const leaveTeam = (teamID: number, userTeamID: number): Promise<*> => {
return axiosInstance.delete(teamUrl).then(({ data }) => data.teams);
};
export const fetchCurrentTeam = (): Promise<*> =>
export const getCurrentTeam = (): Promise<*> =>
axiosInstance.get(CURRENT_TEAM_PATH).then(({ data }) => data.team);

View file

@ -1,14 +0,0 @@
module Datatables
class DatatablesTeam < ApplicationRecord
belongs_to :user
default_scope { order(name: :asc) }
private
# this isn't strictly necessary, but it will prevent
# rails from calling save, which would fail anyway.
def readonly?
true
end
end
end

View file

@ -198,7 +198,7 @@ class User < ApplicationRecord
has_many :user_notifications, inverse_of: :user
has_many :notifications, through: :user_notifications
has_many :zip_exports, inverse_of: :user, dependent: :destroy
has_many :datatables_teams, class_name: '::Datatables::DatatablesTeam'
has_many :datatables_teams, class_name: '::Views::Datatables::DatatablesTeam'
# If other errors besides parameter "avatar" exist,
# they will propagate to "avatar" also, so remove them

View file

@ -0,0 +1,16 @@
module Views
module Datatables
class DatatablesTeam < ApplicationRecord
belongs_to :user
default_scope { order(name: :asc) }
private
# this isn't strictly necessary, but it will prevent
# rails from calling save, which would fail anyway.
def readonly?
true
end
end
end
end

View file

@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe Datatables::DatatablesTeam, type: :model do
RSpec.describe Views::Datatables::DatatablesTeam, type: :model do
describe 'Database table' do
it { should have_db_column :id }
it { should have_db_column :name }
@ -15,9 +15,9 @@ RSpec.describe Datatables::DatatablesTeam, type: :model do
let(:user) { create :user }
it do
expect {
Datatables::DatatablesTeam.create!(user_id: user.id)
Views::Datatables::DatatablesTeam.create!(user_id: user.id)
}.to raise_error(ActiveRecord::ReadOnlyRecord,
'Datatables::DatatablesTeam is marked as readonly')
'Views::Datatables::DatatablesTeam is marked as readonly')
end
end
end

View file

@ -57,7 +57,9 @@ describe ClientApi::TeamsService do
it 'should return an array of valid teams' do
create :user_team, user: user_one, team: team_one
expect(team_service.teams_data).to match_response_schema('teams')
expect(team_service.teams_data).to(
match_response_schema('datatables_teams')
)
end
end