mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-27 10:08:11 +08:00
create view directory per @Ducz0r 's request
This commit is contained in:
parent
9eac014f1a
commit
e0b6683a44
8 changed files with 25 additions and 21 deletions
|
@ -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";
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
16
app/models/views/datatables/datatables_team.rb
Normal file
16
app/models/views/datatables/datatables_team.rb
Normal 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
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue